Coverage for tests/test_NaiveCentroid.py: 50%

38 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-01 12:04 +0000

1# This file is part of meas_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://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 <https://www.gnu.org/licenses/>. 

21 

22import unittest 

23 

24import lsst.geom 

25from lsst.meas.base.tests import (AlgorithmTestCase, CentroidTransformTestCase, 

26 SingleFramePluginTransformSetupHelper) 

27import lsst.utils.tests 

28 

29 

30class NaiveCentroidTestCase(AlgorithmTestCase, lsst.utils.tests.TestCase): 

31 

32 def setUp(self): 

33 self.center = lsst.geom.Point2D(50.1, 49.8) 

34 self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(-20, -30), 

35 lsst.geom.Extent2I(140, 160)) 

36 self.dataset = lsst.meas.base.tests.TestDataset(self.bbox) 

37 self.dataset.addSource(100000.0, self.center) 

38 

39 def tearDown(self): 

40 del self.center 

41 del self.bbox 

42 del self.dataset 

43 

44 def testSingleFramePlugin(self): 

45 task = self.makeSingleFrameMeasurementTask("base_NaiveCentroid") 

46 exposure, catalog = self.dataset.realize(10.0, task.schema, randomSeed=0) 

47 task.run(catalog, exposure) 

48 record = catalog[0] 

49 x = record.get("base_NaiveCentroid_x") 

50 y = record.get("base_NaiveCentroid_y") 

51 self.assertFalse(record.get("base_NaiveCentroid_flag")) 

52 self.assertFloatsAlmostEqual(x, self.center.getX(), atol=2.) 

53 self.assertFloatsAlmostEqual(y, self.center.getY(), atol=2.) 

54 

55 

56class NaiveCentroidTransformTestCase(CentroidTransformTestCase, 

57 SingleFramePluginTransformSetupHelper, 

58 lsst.utils.tests.TestCase): 

59 controlClass = lsst.meas.base.NaiveCentroidControl 

60 algorithmClass = lsst.meas.base.NaiveCentroidAlgorithm 

61 transformClass = lsst.meas.base.NaiveCentroidTransform 

62 flagNames = ('flag', 'flag_noCounts', 'flag_edge') 

63 singleFramePlugins = ('base_NaiveCentroid',) 

64 forcedPlugins = ('base_NaiveCentroid',) 

65 

66 

67class TestMemory(lsst.utils.tests.MemoryTestCase): 

68 pass 

69 

70 

71def setup_module(module): 

72 lsst.utils.tests.init() 

73 

74 

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

76 lsst.utils.tests.init() 

77 unittest.main()