Coverage for tests/test_filters.py: 45%
40 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-12 09:11 +0000
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-12 09:11 +0000
1# This file is part of obs_base.
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/>.
22import unittest
24import lsst.afw.image
25import lsst.pex.exceptions
26import lsst.utils.tests
27from lsst.obs.base import FilterDefinition, FilterDefinitionCollection
30class TestFilterDefinitionCollection(lsst.utils.tests.TestCase):
31 def setUp(self):
32 self.filters1 = FilterDefinitionCollection(
33 FilterDefinition(physical_filter="abc"),
34 FilterDefinition(physical_filter="def", band="d", doc="This is a test filter."),
35 )
36 self.filters2 = FilterDefinitionCollection(
37 FilterDefinition(physical_filter="abc"),
38 FilterDefinition(physical_filter="def", band="dd"),
39 )
41 def test_findAll(self):
42 self.assertEqual(set(self.filters1.findAll("r")), set())
43 matches = self.filters1.findAll("abc")
44 self.assertEqual(len(matches), 1)
45 match = list(matches)[0]
46 self.assertEqual(match.physical_filter, "abc")
48 def test_physical_to_band(self):
49 """Test that the physical_to_band dict returns expected values."""
50 self.assertIsNone(self.filters1.physical_to_band["abc"])
51 self.assertEqual(self.filters1.physical_to_band["def"], "d")
52 self.assertIsNone(self.filters2.physical_to_band["abc"])
53 self.assertEqual(self.filters2.physical_to_band["def"], "dd")
56class TestFilterDefinition(lsst.utils.tests.TestCase):
57 def setUp(self):
58 self.filter_g = FilterDefinition(band="g", physical_filter="HSC-G", alias={"ABCDEFG"})
59 self.filter_g2 = FilterDefinition(band="g", physical_filter="HSC-G2", afw_name="g2", alias={"HIJK"})
61 self.physical_only = FilterDefinition(physical_filter="physical")
62 self.afw_name = FilterDefinition(physical_filter="afw_name", afw_name="afw only")
63 self.abstract = FilterDefinition(physical_filter="abstract", band="abstract only")
65 def test_physical_only(self):
66 """physical_filter is the only name this filter has."""
67 self.assertEqual(
68 self.physical_only.makeFilterLabel(), lsst.afw.image.FilterLabel(physical="physical")
69 )
71 def test_afw_name(self):
72 """afw_name is the Filter name, physical_filter is an alias."""
73 self.assertEqual(self.afw_name.makeFilterLabel(), lsst.afw.image.FilterLabel(physical="afw_name"))
75 def test_abstract_only(self):
76 """band is the Filter name, physical_filter is an alias."""
77 self.assertEqual(
78 self.abstract.makeFilterLabel(),
79 lsst.afw.image.FilterLabel(band="abstract only", physical="abstract"),
80 )
83class MemoryTester(lsst.utils.tests.MemoryTestCase):
84 pass
87def setup_module(module):
88 lsst.utils.tests.init()
91if __name__ == "__main__": 91 ↛ 92line 91 didn't jump to line 92, because the condition on line 91 was never true
92 lsst.utils.tests.init()
93 unittest.main()