Coverage for tests/test_tractInfo.py: 29%

42 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-03 09:23 +0000

1import unittest 

2import numpy as np 

3 

4import lsst.utils.tests 

5import lsst.geom 

6 

7from lsst.skymap.discreteSkyMap import DiscreteSkyMap 

8 

9 

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() 

21 

22 self.skymap = DiscreteSkyMap(config=config) 

23 

24 def testProperties(self): 

25 """Test accessing via properties.""" 

26 tractInfo = self.skymap[0] 

27 

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()) 

39 

40 def testContains(self): 

41 """Simple tests for the contains method, including bad inputs.""" 

42 tractInfo = self.skymap[0] 

43 coord = tractInfo.ctr_coord 

44 

45 self.assertTrue(tractInfo.contains(coord)) 

46 

47 badCoord = lsst.geom.SpherePoint(np.nan*lsst.geom.degrees, 0.0*lsst.geom.degrees) 

48 self.assertFalse(tractInfo.contains(badCoord)) 

49 

50 badCoord = lsst.geom.SpherePoint(0.0*lsst.geom.degrees, np.nan*lsst.geom.degrees) 

51 self.assertFalse(tractInfo.contains(badCoord)) 

52 

53 

54class MemoryTester(lsst.utils.tests.MemoryTestCase): 

55 pass 

56 

57 

58def setup_module(module): 

59 lsst.utils.tests.init() 

60 

61 

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()