Coverage for tests / test_binImageData.py: 21%
44 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-26 09:10 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-26 09:10 +0000
1# This file is part of ip_isr.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
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 GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
21import unittest
23import lsst.utils.tests
24import lsst.afw.image as afwImage
25from lsst.ip.isr.binImageDataTask import binImageData
28class BinImageDataTestCases(lsst.utils.tests.TestCase):
30 def setUp(self):
31 """Set up the various image and image-like data type inputs,
32 plus reference images that represent the expected output from
33 an 8x8 binning.
34 """
35 self.imageF = afwImage.ImageF(2048, 2048)
36 self.imageF.set(100)
37 self.miF = afwImage.makeMaskedImage(self.imageF)
38 self.expF = afwImage.makeExposure(self.miF)
40 self.imageI = afwImage.ImageI(2048, 2048)
41 self.imageI.set(100)
42 self.miI = afwImage.makeMaskedImage(self.imageI)
43 self.expI = afwImage.makeExposure(self.miI)
45 self.refImageF = afwImage.ImageF(256, 256)
46 self.refImageF.set(100)
47 self.refMiF = afwImage.makeMaskedImage(self.refImageF)
48 self.refExpF = afwImage.makeExposure(self.refMiF)
50 self.refImageI = afwImage.ImageI(256, 256)
51 self.refImageI.set(100)
52 self.refMiI = afwImage.makeMaskedImage(self.refImageI)
53 self.refExpI = afwImage.makeExposure(self.refMiI)
55 def test_ImageDataBinning(self):
56 """Test an 8x8 binning."""
57 images = [(self.imageF, self.refImageF), (self.imageI, self.refImageI)]
58 maskedImages = [(self.miF, self.refMiF), (self.miI, self.refMiI)]
59 exposures = [(self.expF, self.refExpF), (self.expI, self.refExpI)]
61 for input, ref in images:
62 binnedData = binImageData(input, binFactor=8)
63 self.assertImagesEqual(ref, binnedData)
64 for input, ref in maskedImages:
65 binnedData = binImageData(input, binFactor=8)
66 self.assertMaskedImagesEqual(ref, binnedData)
67 for input, ref in exposures:
68 binnedData = binImageData(input, binFactor=8)
69 self.assertMaskedImagesEqual(
70 ref.getMaskedImage(), binnedData.getMaskedImage()
71 )
73 def test_BinImageDataTypes(self):
74 """Test that a TypeError is raised should the input
75 not be of type `lsst.afw.image.Image`, `lsst.afw.image.MaskedImage`, or
76 `lsst.afw.image.Exposure, or one of their sub-types.
77 """
78 with self.assertRaises(TypeError):
79 _ = binImageData(None)
82def setup_module(module):
83 lsst.utils.tests.init()
86if __name__ == "__main__": 86 ↛ 87line 86 didn't jump to line 87 because the condition on line 86 was never true
87 import sys
89 setup_module(sys.modules[__name__])
90 unittest.main()