Exemplo n.º 1
0
    def test_plot_axy_lines_are_set_to_width_of_below_default(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)
        x, y = np.arange(10.), np.arange(10.) * 2

        plotter.plot_y_line(x, y)
        self.axy.plot.assert_called_once_with(y, x, scaley=False)
        self.assert_that_a_call_has_been_made_to_this_object_containing_linewidth_and_half(
            self.axy.plot)
Exemplo n.º 2
0
    def test_remove_line_plot_axes_sets_label_visibility(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)

        plotter._remove_line_plots()

        # check has removed third and second axes in that order
        expected_calls = [call(2), call().remove(), call(1), call().remove()]
        self.image_axes.figure.axes.__getitem__.assert_has_calls(
            expected_calls, any_order=False)
        for mock_axis in [
                self.image_axes.get_xaxis(),
                self.image_axes.get_yaxis()
        ]:
            mock_axis.set_visible.assert_called_with(True)
Exemplo n.º 3
0
    def test_plot_with_line_present_sets_data(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)
        x, y = np.arange(10.), np.arange(10.) * 2
        plotter.plot_x_line(x, y)
        plotter.plot_y_line(x, y)
        self.axx.reset_mock()
        self.axy.reset_mock()

        plotter.plot_x_line(x, y)
        plotter.plot_y_line(x, y)

        plotter._xfig.set_data.assert_called_once_with(x, y)
        plotter._yfig.set_data.assert_called_once_with(y, x)
        self.axx.plot.assert_not_called()
        self.axy.plot.assert_not_called()
Exemplo n.º 4
0
    def test_delete_plot_lines_with_plots_present(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)
        xfig, yfig = MagicMock(), MagicMock()
        self.axx.plot.side_effect = [[xfig]]
        self.axy.plot.side_effect = [[yfig]]
        x, y = np.arange(10.), np.arange(10.)
        plotter.plot_x_line(x, y)
        plotter.plot_y_line(x, y)

        plotter.delete_line_plot_lines()

        xfig.remove.assert_called_once()
        yfig.remove.assert_called_once()
Exemplo n.º 5
0
    def add_line_plots(self, toolcls, exporter):
        """Assuming line plots are currently disabled, enable them on the current figure
        The image axes must have been created first.
        :param toolcls: Use this class to handle creating the plots
        :param exporter: Object defining methods to export cuts/roi
        """
        if self.line_plots_active:
            return

        self.line_plots_active = True
        self._line_plots = toolcls(LinePlots(self.ax, self.colorbar), exporter)
        self.status_bar_label.setText(self._line_plots.status_message())
        self.canvas.setFocus()
        self.mpl_toolbar.set_action_checked(ToolItemText.LINEPLOTS, True, trigger=False)
Exemplo n.º 6
0
    def test_construction_adds_line_plots_to_axes(self, mock_gridspec):
        gs = mock_gridspec()
        mock_gridspec.reset_mock()
        LinePlots(self.image_axes, self.mock_colorbar)

        fig = self.image_axes.figure
        self.assertEqual(2, fig.add_subplot.call_count)
        self.assertEqual(1, mock_gridspec.call_count)
        # use spaces at 0, 1 & 3 in grid
        gs.__getitem__.assert_has_calls((call(0), call(1), call(3)),
                                        any_order=True)
        self.assertTrue('sharey' in fig.add_subplot.call_args_list[0][1]
                        or 'sharey' in fig.add_subplot.call_args_list[1][1])
        self.assertTrue('sharex' in fig.add_subplot.call_args_list[0][1]
                        or 'sharex' in fig.add_subplot.call_args_list[1][1])
        for mock_axis in [
                self.image_axes.get_xaxis(),
                self.image_axes.get_yaxis()
        ]:
            mock_axis.set_visible.assert_called_once_with(False)
Exemplo n.º 7
0
    def test_plot_with_no_line_present_creates_line_artist(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)
        self.axx.set_xlabel.reset_mock()
        x, y = np.arange(10.), np.arange(10.) * 2

        plotter.plot_x_line(x, y)
        self.axx.plot.assert_called_once_with(x, y, scalex=False)
        self.axx.set_xlabel.assert_called_once_with(
            self.image_axes.get_xlabel())

        self.axy.set_ylabel.reset_mock()
        self.axy.set_xlim.reset_mock()
        plotter.plot_y_line(x, y)
        self.axy.plot.assert_called_once_with(y, x, scaley=False)
        self.axy.set_ylabel.assert_called_once_with(
            self.image_axes.get_ylabel())
Exemplo n.º 8
0
    def test_delete_plot_lines_handles_empty_plots(self):
        plotter = LinePlots(self.image_axes, self.mock_colorbar)

        plotter.delete_line_plot_lines()