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)
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()
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()
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])
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())
def test_delete_plot_lines_handles_empty_plots(self): plotter = LinePlots(self.image_axes, self.mock_colorbar) plotter.delete_line_plot_lines()