Coverage for tests/test_genericPlotAction.py: 49%
33 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-24 04:10 -0700
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-24 04:10 -0700
1# This file is part of analysis_tools.
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 <http://www.gnu.org/licenses/>.
22from unittest import TestCase, main
24import lsst.utils.tests
25import matplotlib.pyplot as plt
26from lsst.analysis.tools.atools.genericPlotAction import StructPlotAction
27from lsst.analysis.tools.interfaces import AnalysisTool, JointAction, NoMetric, PlotAction
30class NullPlot(PlotAction):
31 def __call__(self, data, **kwargs):
32 fig = plt.figure()
33 return fig
36class CustomPlot(NullPlot):
37 def getPlotType(self) -> str:
38 return "Custom"
41class LoadFromPipelineTestCase(TestCase):
42 """Test that analysis tools can be loaded from a pipeline"""
44 def setUp(self) -> None:
45 super().setUp()
46 action_plot = StructPlotAction()
47 action_plot.actions.hist = NullPlot()
48 action_plot.actions.xy = CustomPlot()
49 action_joint = JointAction(metric=NoMetric(), plot=action_plot)
50 self.action_joint = action_joint
51 tool = AnalysisTool()
52 tool.produce = action_joint
53 self.tool = tool
55 def testJoint(self) -> None:
56 results = self.tool({})
57 assert tuple(results.keys()) == ("hist_NullPlot", "xy_Custom")
60class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
61 pass
64def setup_module(module):
65 lsst.utils.tests.init()
68if __name__ == "__main__": 68 ↛ 69line 68 didn't jump to line 69, because the condition on line 68 was never true
69 lsst.utils.tests.init()
70 main()