Coverage for tests/test_tractInfo.py: 35%
42 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-14 02:51 -0700
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-14 02:51 -0700
1import unittest
2import numpy as np
4import lsst.utils.tests
5import lsst.geom
7from lsst.skymap.discreteSkyMap import DiscreteSkyMap
10class TractInfoTestCase(lsst.utils.tests.TestCase):
11 def setUp(self):
12 # These are from the PS1 Medium-Deep fields
13 coords = [(10.6750, 41.2667), # M31
14 (36.2074, -04.5833), # XMM-LSS
15 ]
16 config = DiscreteSkyMap.ConfigClass()
17 config.raList = [c[0] for c in coords]
18 config.decList = [c[1] for c in coords]
19 config.radiusList = [2] * len(coords)
20 config.validate()
22 self.skymap = DiscreteSkyMap(config=config)
24 def testProperties(self):
25 """Test accessing via properties."""
26 tractInfo = self.skymap[0]
28 self.assertEqual(tractInfo.bbox, tractInfo.getBBox())
29 self.assertEqual(tractInfo.ctr_coord, tractInfo.getCtrCoord())
30 self.assertEqual(tractInfo.tract_id, tractInfo.getId())
31 self.assertEqual(tractInfo.num_patches, tractInfo.getNumPatches())
32 self.assertEqual(tractInfo.patch_border, tractInfo.getPatchBorder())
33 self.assertEqual(tractInfo.patch_inner_dimensions, tractInfo.getPatchInnerDimensions())
34 self.assertEqual(tractInfo.tract_overlap, tractInfo.getTractOverlap())
35 self.assertEqual(tractInfo.vertex_list, tractInfo.getVertexList())
36 self.assertEqual(tractInfo.inner_sky_polygon, tractInfo.getInnerSkyPolygon())
37 self.assertEqual(tractInfo.outer_sky_polygon, tractInfo.getOuterSkyPolygon())
38 self.assertEqual(tractInfo.wcs, tractInfo.getWcs())
40 def testContains(self):
41 """Simple tests for the contains method, including bad inputs."""
42 tractInfo = self.skymap[0]
43 coord = tractInfo.ctr_coord
45 self.assertTrue(tractInfo.contains(coord))
47 badCoord = lsst.geom.SpherePoint(np.nan*lsst.geom.degrees, 0.0*lsst.geom.degrees)
48 self.assertFalse(tractInfo.contains(badCoord))
50 badCoord = lsst.geom.SpherePoint(0.0*lsst.geom.degrees, np.nan*lsst.geom.degrees)
51 self.assertFalse(tractInfo.contains(badCoord))
54class MemoryTester(lsst.utils.tests.MemoryTestCase):
55 pass
58def setup_module(module):
59 lsst.utils.tests.init()
62if __name__ == "__main__": 62 ↛ 63line 62 didn't jump to line 63, because the condition on line 62 was never true
63 lsst.utils.tests.init()
64 unittest.main()