Coverage for tests/test_footprintEllipse.py: 39%
31 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-19 04:54 -0700
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-19 04:54 -0700
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
23import math
24import unittest
26import lsst.utils.tests
27import lsst.afw.geom as afwGeom
28import lsst.afw.detection as afwDet
31class FootprintTestCase(lsst.utils.tests.TestCase):
33 def testCircle(self):
34 xc, yc = 30, 50
35 radius = 10
37 spanSet = afwGeom.SpanSet.fromShape(radius).shiftedBy(xc, yc)
38 test = afwDet.Footprint(spanSet)
40 # Here's how it used to be done using circles, before #1556
41 r2 = int(radius**2 + 0.5)
42 r = int(math.sqrt(r2))
43 spanList = []
44 for i in range(-r, r+1):
45 hlen = int(math.sqrt(r2 - i**2))
46 spanList.append(afwGeom.Span(yc + i, xc - hlen, xc + hlen))
47 control = afwDet.Footprint(afwGeom.SpanSet(spanList))
49 self.assertEqual(len(test.getSpans()), len(control.getSpans()))
50 for s0, s1 in zip(test.getSpans(), control.getSpans()):
51 self.assertEqual(s0.getX0(), s1.getX0())
52 self.assertEqual(s0.getX1(), s1.getX1())
53 self.assertEqual(s0.getY(), s1.getY())
54 self.assertEqual(test.getArea(), control.getArea())
57class MemoryTester(lsst.utils.tests.MemoryTestCase):
58 pass
61def setup_module(module):
62 lsst.utils.tests.init()
65if __name__ == "__main__": 65 ↛ 66line 65 didn't jump to line 66, because the condition on line 65 was never true
66 lsst.utils.tests.init()
67 unittest.main()