Coverage for tests/test_fakes.py: 43%

42 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-12-01 21:12 +0000

1# 

2# LSST Data Management System 

3# Copyright 2008-2013 LSST Corporation. 

4# 

5# This product includes software developed by the 

6# LSST Project (http://www.lsst.org/). 

7# 

8# This program is free software: you can redistribute it and/or modify 

9# it under the terms of the GNU General Public License as published by 

10# the Free Software Foundation, either version 3 of the License, or 

11# (at your option) any later version. 

12# 

13# This program is distributed in the hope that it will be useful, 

14# but WITHOUT ANY WARRANTY; without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the LSST License Statement and 

19# the GNU General Public License along with this program. If not, 

20# see <http://www.lsstcorp.org/LegalNotices/>. 

21# 

22 

23import unittest 

24 

25import lsst.utils 

26import lsst.afw.image 

27import lsst.utils.tests 

28import lsst.pipe.tasks.fakes as fakes 

29 

30 

31class TrialFakeSourcesConfig(fakes.BaseFakeSourcesConfig): 

32 pass 

33 

34 

35class TrialFakeSourcesTask(fakes.BaseFakeSourcesTask): 

36 ConfigClass = TrialFakeSourcesConfig 

37 

38 def __init__(self, **kwargs): 

39 fakes.BaseFakeSourcesTask.__init__(self, **kwargs) 

40 

41 def run(self, exposure, background): 

42 pass 

43 

44 

45class TestFakes(lsst.utils.tests.TestCase): 

46 

47 def testFakeMaskAdded(self): 

48 ''' 

49 Test that the FAKE mask plane does not exist, that it is added, and the instance's 

50 bitmask points to the correct plane 

51 ''' 

52 maskPlaneName = "FAKE" 

53 maskKeysBefore = list(lsst.afw.image.Mask().getMaskPlaneDict()) 

54 trialInstance = TrialFakeSourcesTask() 

55 maskKeysAfter = list(lsst.afw.image.Mask().getMaskPlaneDict()) 

56 maskPlaneName = trialInstance.config.maskPlaneName 

57 self.assertNotIn(maskPlaneName, maskKeysBefore) 

58 self.assertIn(maskPlaneName, maskKeysAfter) 

59 self.assertEqual(trialInstance.bitmask, lsst.afw.image.Mask[lsst.afw.image.MaskPixel] 

60 .getPlaneBitMask(maskPlaneName)) 

61 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].removeMaskPlane(maskPlaneName) 

62 del trialInstance 

63 

64 def testFakeMasked(self): 

65 ''' 

66 Test that if the FAKE mask plane exists, it is used, and that the instance's bitmask 

67 points to the correct plane 

68 ''' 

69 maskPlaneName = "FAKE" 

70 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].addMaskPlane(maskPlaneName) 

71 maskKeysBefore = list(lsst.afw.image.Mask().getMaskPlaneDict()) 

72 self.assertIn(maskPlaneName, maskKeysBefore) 

73 maskPlaneBitMask = lsst.afw.image.Mask[lsst.afw.image.MaskPixel].getPlaneBitMask(maskPlaneName) 

74 trialInstance = TrialFakeSourcesTask() 

75 self.assertEqual(maskPlaneBitMask, trialInstance.bitmask) 

76 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].removeMaskPlane(maskPlaneName) 

77 del trialInstance 

78 

79 

80def setup_module(module): 

81 lsst.utils.tests.init() 

82 

83 

84class MatchMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

85 pass 

86 

87 

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