Coverage for tests / test_genericPlotAction.py: 49%

33 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-23 09:01 +0000

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/>. 

21 

22from unittest import TestCase, main 

23 

24import matplotlib.pyplot as plt 

25 

26import lsst.utils.tests 

27from lsst.analysis.tools.atools.genericPlotAction import StructPlotAction 

28from lsst.analysis.tools.interfaces import AnalysisTool, JointAction, NoMetric, PlotAction 

29 

30 

31class NullPlot(PlotAction): 

32 def __call__(self, data, **kwargs): 

33 fig = plt.figure() 

34 return fig 

35 

36 

37class CustomPlot(NullPlot): 

38 def getPlotType(self) -> str: 

39 return "Custom" 

40 

41 

42class StructPlotActionTestCase(TestCase): 

43 """Test the generic StructPlotAction""" 

44 

45 def setUp(self) -> None: 

46 super().setUp() 

47 action_plot = StructPlotAction() 

48 action_plot.actions.hist = NullPlot() 

49 action_plot.actions.xy = CustomPlot() 

50 action_joint = JointAction(metric=NoMetric(), plot=action_plot) 

51 self.action_joint = action_joint 

52 tool = AnalysisTool() 

53 tool.produce = action_joint 

54 self.tool = tool 

55 

56 def testTool(self) -> None: 

57 results = self.tool({}) 

58 assert tuple(results.keys()) == ("hist_NullPlot", "xy_Custom") 

59 

60 

61class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

62 pass 

63 

64 

65def setup_module(module): 

66 lsst.utils.tests.init() 

67 

68 

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

70 lsst.utils.tests.init() 

71 main()