Coverage for tests / test_histPlot.py: 38%

35 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-25 08:55 +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 <https://www.gnu.org/licenses/>. 

21 

22 

23import unittest 

24 

25import matplotlib 

26import matplotlib.pyplot as plt 

27 

28import lsst.utils.tests 

29from lsst.analysis.tools.actions.plot.histPlot import HistPanel, HistPlot 

30 

31matplotlib.use("Agg") 

32 

33 

34class HistPlotLayoutTestCase(lsst.utils.tests.TestCase): 

35 def setUp(self): 

36 self.plot = HistPlot() 

37 for panel_name in ("panel_a", "panel_b", "panel_c"): 

38 self.plot.panels[panel_name] = HistPanel() 

39 self.plot.panels[panel_name].hists = {f"{panel_name}_hist": panel_name} 

40 

41 def test_default_layout_uses_two_columns(self): 

42 fig = plt.figure() 

43 

44 axes, ncols, nrows = self.plot._makeAxes(fig) 

45 

46 self.assertEqual(ncols, 2) 

47 self.assertEqual(nrows, 2) 

48 self.assertEqual(len(axes), 3) 

49 

50 def test_panels_per_row_one_stacks_vertically(self): 

51 self.plot.panelsPerRow = 1 

52 fig = plt.figure() 

53 

54 axes, ncols, nrows = self.plot._makeAxes(fig) 

55 

56 self.assertEqual(ncols, 1) 

57 self.assertEqual(nrows, 3) 

58 self.assertEqual(len(axes), 3) 

59 self.assertTrue(all(ax.get_position().x0 == axes[0].get_position().x0 for ax in axes[1:])) 

60 self.assertGreater(axes[0].get_position().y0, axes[1].get_position().y0) 

61 self.assertGreater(axes[1].get_position().y0, axes[2].get_position().y0) 

62 

63 

64class MemoryTester(lsst.utils.tests.MemoryTestCase): 

65 pass 

66 

67 

68def setup_module(module): 

69 lsst.utils.tests.init() 

70 

71 

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

73 lsst.utils.tests.init() 

74 unittest.main()