Coverage for tests/test_clipFootprintToNonZeroImpl.py: 52%
25 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-12 02:57 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-12 02:57 -0800
1#
2# LSST Data Management System
3#
4# Copyright 2008-2017 AURA/LSST.
5#
6# This product includes software developed by the
7# LSST Project (http://www.lsst.org/).
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the LSST License Statement and
20# the GNU General Public License along with this program. If not,
21# see <https://www.lsstcorp.org/LegalNotices/>.
22#
23import unittest
25import lsst.utils.tests
26import lsst.afw.detection as afwDet
27import lsst.geom as geom
28import lsst.afw.geom as afwGeom
29import lsst.afw.image as afwImage
30from lsst.meas.deblender.plugins import clipFootprintToNonzeroImpl
33class ClipFootprintTestCase(lsst.utils.tests.TestCase):
34 """This is s a test to verify that clipping footprints to a non-zero region
35 works as intended. It is expected that spans which contain leading or
36 trailing zeros will be trimmed as to not include these values, while zeros
37 which occur inside a span will be preserved.
38 """
39 def testClip(self):
40 im = afwImage.ImageI(geom.Box2I(geom.Point2I(-2, -2),
41 geom.Extent2I(20, 20)))
43 span1 = afwGeom.SpanSet.fromShape(5, afwGeom.Stencil.BOX, (6, 6))
44 span1.setImage(im, 20)
46 im.getArray()[6+2, 6+2] = 0
48 # Set some negative pixels to ensure they are not clipped
49 im.getArray()[12, :] *= -1
51 span2 = afwGeom.SpanSet.fromShape(6, afwGeom.Stencil.BOX, (6, 6))
53 foot = afwDet.Footprint(span2)
55 clipFootprintToNonzeroImpl(foot, im)
57 self.assertEqual(foot.spans, span1)
60class TestMemory(lsst.utils.tests.MemoryTestCase):
61 pass
64def setup_module(module):
65 lsst.utils.tests.init()
68if __name__ == "__main__": 68 ↛ 69line 68 didn't jump to line 69, because the condition on line 68 was never true
69 lsst.utils.tests.init()
70 unittest.main()