Coverage for tests/test_NaiveCentroid.py: 49%
35 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-04 02:37 -0700
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-04 02:37 -0700
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/>.
22import unittest
24import lsst.geom
25from lsst.meas.base.tests import (AlgorithmTestCase, CentroidTransformTestCase,
26 SingleFramePluginTransformSetupHelper)
27import lsst.utils.tests
30# Remove this file on DM-41701
32class NaiveCentroidTestCase(AlgorithmTestCase, lsst.utils.tests.TestCase):
34 def setUp(self):
35 self.center = lsst.geom.Point2D(50.1, 49.8)
36 self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(-20, -30),
37 lsst.geom.Extent2I(140, 160))
38 self.dataset = lsst.meas.base.tests.TestDataset(self.bbox)
39 self.dataset.addSource(100000.0, self.center)
41 def testSingleFramePlugin(self):
42 # import os; print(os.getpid()); import ipdb; ipdb.set_trace();
43 with self.assertWarnsRegex(FutureWarning, "Plugin 'NaiveCentroid' is deprecated"):
44 task = self.makeSingleFrameMeasurementTask("base_NaiveCentroid")
45 exposure, catalog = self.dataset.realize(10.0, task.schema, randomSeed=0)
46 task.run(catalog, exposure)
47 record = catalog[0]
48 x = record.get("base_NaiveCentroid_x")
49 y = record.get("base_NaiveCentroid_y")
50 self.assertFalse(record.get("base_NaiveCentroid_flag"))
51 self.assertFloatsAlmostEqual(x, self.center.getX(), atol=2.)
52 self.assertFloatsAlmostEqual(y, self.center.getY(), atol=2.)
55class NaiveCentroidTransformTestCase(CentroidTransformTestCase,
56 SingleFramePluginTransformSetupHelper,
57 lsst.utils.tests.TestCase):
58 controlClass = lsst.meas.base.NaiveCentroidControl
59 algorithmClass = lsst.meas.base.NaiveCentroidAlgorithm
60 transformClass = lsst.meas.base.NaiveCentroidTransform
61 flagNames = ('flag', 'flag_noCounts', 'flag_edge')
62 singleFramePlugins = ('base_NaiveCentroid',)
63 forcedPlugins = ('base_NaiveCentroid',)
66class TestMemory(lsst.utils.tests.MemoryTestCase):
67 pass
70def setup_module(module):
71 lsst.utils.tests.init()
74if __name__ == "__main__": 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 lsst.utils.tests.init()
76 unittest.main()