Coverage for tests/test_packers.py : 47%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of skymap.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://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 <http://www.gnu.org/licenses/>.
22import unittest
24import lsst.utils.tests
26try:
27 from lsst.daf.butler import ExpandedDataCoordinate, DimensionUniverse, DimensionGraph, DataCoordinate
28 HAVE_DAF_BUTLER = True
29except ImportError:
30 HAVE_DAF_BUTLER = False
32from lsst.skymap.packers import SkyMapDimensionPacker
35@unittest.skipUnless(HAVE_DAF_BUTLER, "daf_butler not setup")
36class SkyMapDimensionPackerTestCase(lsst.utils.tests.TestCase):
38 def setUp(self):
39 self.universe = DimensionUniverse()
40 self.fixed = ExpandedDataCoordinate(
41 DimensionGraph(universe=self.universe, names=["skymap"]),
42 values=("unimportant",),
43 records={
44 "skymap": self.universe["skymap"].RecordClass.fromDict({
45 "name": "unimportant",
46 "tract_max": 5,
47 "patch_nx_max": 3,
48 "patch_ny_max": 3,
49 })
50 })
52 def testWithoutFilter(self):
53 dimensions = DimensionGraph(universe=self.universe, names=["tract", "patch"])
54 dataId = DataCoordinate.standardize(
55 skymap=self.fixed["skymap"],
56 tract=2,
57 patch=6,
58 universe=self.universe
59 )
60 packer = SkyMapDimensionPacker(self.fixed, dimensions)
61 packedId = packer.pack(dataId)
62 self.assertLessEqual(packedId.bit_length(), packer.maxBits)
63 self.assertEqual(packer.unpack(packedId), dataId)
65 def testWithFilter(self):
66 dimensions = DimensionGraph(universe=self.universe, names=["tract", "patch", "abstract_filter"])
67 dataId = DataCoordinate.standardize(
68 skymap=self.fixed["skymap"],
69 tract=2,
70 patch=6,
71 abstract_filter="g",
72 universe=self.universe
73 )
74 packer = SkyMapDimensionPacker(self.fixed, dimensions)
75 packedId = packer.pack(dataId)
76 self.assertLessEqual(packedId.bit_length(), packer.maxBits)
77 self.assertEqual(packer.unpack(packedId), dataId)
80class MemoryTester(lsst.utils.tests.MemoryTestCase):
81 pass
84def setup_module(module):
85 lsst.utils.tests.init()
88if __name__ == "__main__": 88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true
89 lsst.utils.tests.init()
90 unittest.main()