示例#1
0
    def testSpanShift(self):
        """Test our ability to shift spans"""

        span = afwDetect.Span(10, 100, 105)
        foot = afwDetect.Footprint()

        foot.addSpan(span, 1, 2)

        bbox = foot.getBBox()
        self.assertEqual(bbox.getWidth(), 6)
        self.assertEqual(bbox.getHeight(), 1)
        self.assertEqual(bbox.getMinX(), 101)
        self.assertEqual(bbox.getMinY(), 12)
        #
        # Shift that span using Span.shift
        #
        foot = afwDetect.Footprint()
        span.shift(-1, -2)
        foot.addSpan(span)

        bbox = foot.getBBox()
        self.assertEqual(bbox.getWidth(), 6)
        self.assertEqual(bbox.getHeight(), 1)
        self.assertEqual(bbox.getMinX(), 99)
        self.assertEqual(bbox.getMinY(), 8)
示例#2
0
    def testLessThan(self):
        span1 = afwDetect.Span(42, 0, 100);
        span2 = afwDetect.Span(41, 0, 100);
        span3 = afwDetect.Span(43, 0, 100);
        span4 = afwDetect.Span(42, -100, 100);
        span5 = afwDetect.Span(42, 100, 200);
        span6 = afwDetect.Span(42, 0, 10);
        span7 = afwDetect.Span(42, 0, 200);
        span8 = afwDetect.Span(42, 0, 100);

        def assertOrder(x1, x2):
            self.assertTrue(x1 < x2)
            self.assertFalse(x2 < x1)

        assertOrder(span2, span1)
        assertOrder(span1, span3)
        assertOrder(span4, span1)
        assertOrder(span1, span5)
        assertOrder(span6, span1)
        assertOrder(span1, span7)
        self.assertFalse(span1 < span8)
        self.assertFalse(span8 < span1)
示例#3
0
    def testLessThan(self):
        span1 = afwDetect.Span(42, 0, 100)
        span2 = afwDetect.Span(41, 0, 100)
        span3 = afwDetect.Span(43, 0, 100)
        span4 = afwDetect.Span(42, -100, 100)
        span5 = afwDetect.Span(42, 100, 200)
        span6 = afwDetect.Span(42, 0, 10)
        span7 = afwDetect.Span(42, 0, 200)
        span8 = afwDetect.Span(42, 0, 100)

        # Cannot use assertLess and friends here
        # because Span only has operator <
        def assertOrder(x1, x2):
            self.assertTrue(x1 < x2)
            self.assertFalse(x2 < x1)

        assertOrder(span2, span1)
        assertOrder(span1, span3)
        assertOrder(span4, span1)
        assertOrder(span1, span5)
        assertOrder(span6, span1)
        assertOrder(span1, span7)
        self.assertFalse(span1 < span8)
        self.assertFalse(span8 < span1)
示例#4
0
 def testToString(self):
     y, x0, x1 = 10, 100, 101
     s = afwDetect.Span(y, x0, x1)
     self.assertEqual(s.toString(), toString(y, x0, x1))