Coverage for tests/test_genericPlotAction.py: 49%

33 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-10 11:04 +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 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 

28 

29 

30class NullPlot(PlotAction): 

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

32 fig = plt.figure() 

33 return fig 

34 

35 

36class CustomPlot(NullPlot): 

37 def getPlotType(self) -> str: 

38 return "Custom" 

39 

40 

41class LoadFromPipelineTestCase(TestCase): 

42 """Test that analysis tools can be loaded from a pipeline""" 

43 

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 

54 

55 def testJoint(self) -> None: 

56 results = self.tool({}) 

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

58 

59 

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

61 pass 

62 

63 

64def setup_module(module): 

65 lsst.utils.tests.init() 

66 

67 

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