Coverage for tests / test_coaddBase.py: 38%
33 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:06 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:06 +0000
1# This file is part of pipe_tasks.
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/>.
22from __future__ import annotations
24import unittest
25import lsst.utils.tests
26import numpy as np
28from lsst.afw.image import Mask
29from lsst.afw.math import StatisticsControl
30from lsst.pipe.tasks.coaddBase import (
31 removeMaskPlanes,
32 setRejectedMaskMapping,
33)
36class CoaddBaseTestCase(lsst.utils.tests.TestCase):
38 def setUp(self):
39 self.statsCtrl = StatisticsControl()
40 self.mask = Mask(100, 100)
41 self.mask.array[:, :] = 0
42 self.mask.array[50, 50] = Mask.getPlaneBitMask("BAD")
43 self.mask.array[55, 58:62] = Mask.getPlaneBitMask("CR")
45 def test_removeMaskPlanes(self):
46 """Exercise removeMaskPlanes"""
47 # Test that removing non-existing mask planes does not crash.
48 removeMaskPlanes(self.mask, ["BLAH"])
49 # Test that removing existing mask planes works.
50 for maskPlane in ["BAD", "CR"]:
51 with self.subTest(maskPlane=maskPlane):
52 self.assertGreater((self.mask.array & Mask.getPlaneBitMask(maskPlane)).sum(), 0)
53 removeMaskPlanes(self.mask, [maskPlane])
54 self.assertEqual((self.mask.array & Mask.getPlaneBitMask(maskPlane)).sum(), 0)
56 def test_setRejectedMaskMapping(self):
57 mask_map = setRejectedMaskMapping(self.statsCtrl)
58 self.assertEqual(len(mask_map), 3)
59 # Check that all values are powers of 2
60 for _, v in mask_map:
61 logv = np.log2(v)
62 self.assertEqual(logv, int(logv))
65class TestMemory(lsst.utils.tests.MemoryTestCase):
66 """Check for resource/memory leaks."""
69def setup_module(module): # noqa: D103
70 lsst.utils.tests.init()
73if __name__ == "__main__": 73 ↛ 74line 73 didn't jump to line 74 because the condition on line 73 was never true
74 lsst.utils.tests.init()
75 unittest.main()