Coverage for tests / test_tractInfo.py: 30%

44 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-01 08:22 +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 # TODO: Remove with DM-44799 

37 with self.assertWarns(FutureWarning): 

38 self.assertEqual(tractInfo.inner_sky_polygon, tractInfo.getInnerSkyPolygon()) 

39 self.assertEqual(tractInfo.inner_sky_region, tractInfo.getInnerSkyRegion()) 

40 self.assertEqual(tractInfo.outer_sky_polygon, tractInfo.getOuterSkyPolygon()) 

41 self.assertEqual(tractInfo.wcs, tractInfo.getWcs()) 

42 

43 def testContains(self): 

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

45 tractInfo = self.skymap[0] 

46 coord = tractInfo.ctr_coord 

47 

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

49 

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

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

52 

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

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

55 

56 

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

58 pass 

59 

60 

61def setup_module(module): 

62 lsst.utils.tests.init() 

63 

64 

65if __name__ == "__main__": 65 ↛ 66line 65 didn't jump to line 66 because the condition on line 65 was never true

66 lsst.utils.tests.init() 

67 unittest.main()