コード例 #1
0
ファイル: slice_plot.py プロジェクト: EltayebAhmed/mslice
 def object_clicked(self, target):
     if target in self._legend_dict:
         quick_options(self._legend_dict[target], self)
     else:
         quick_options(target, self)
     self.update_legend()
     self._canvas.draw()
コード例 #2
0
 def test_line_slice(self, qlo_mock):
     plot_figure = MagicMock()
     window = MagicMock()
     plot_figure.window = window
     canvas = MagicMock()
     window.canvas = canvas
     slice_plotter = MagicMock()
     model = SlicePlot(plot_figure, slice_plotter, 'workspace')
     qlo_mock, target = setup_line_values(qlo_mock)
     quick_options(target, model)
     # check view is called with existing line parameters
     qlo_mock.assert_called_with({
         'shown': None,
         'color': '#ff0000',
         'label': u'label1',
         'style': '-',
         'width': '3',
         'marker': 'o',
         'legend': None,
         'error_bar': None
     })
     # check model is updated with parameters from view
     self.assertDictEqual(
         model.get_line_options(target), {
             'shown': None,
             'color': '#0000ff',
             'label': u'label2',
             'style': '--',
             'width': '5',
             'marker': '.',
             'legend': None,
             'error_bar': None
         })
コード例 #3
0
ファイル: slice_plot.py プロジェクト: mantidproject/mslice
 def object_clicked(self, target):
     if target in self._legend_dict:
         quick_options(self._legend_dict[target], self)
     else:
         quick_options(target, self)
     self.update_legend()
     self._canvas.draw()
コード例 #4
0
ファイル: cut_plot.py プロジェクト: mantidproject/mslice
 def plot_clicked(self, x, y):
     bounds = self.calc_figure_boundaries()
     if bounds['x_label'] < y < bounds['title']:
         if bounds['y_label'] < x:
             if y < bounds['x_range']:
                 quick_options('x_range', self, self.x_log)
             elif x < bounds['y_range']:
                 quick_options('y_range', self, self.y_log)
         self._canvas.draw()
コード例 #5
0
ファイル: cut_plot.py プロジェクト: EltayebAhmed/mslice
 def plot_clicked(self, x, y):
     bounds = self.calc_figure_boundaries()
     if bounds['x_label'] < y < bounds['title']:
         if bounds['y_label'] < x:
             if y < bounds['x_range']:
                 quick_options('x_range', self, self.x_log)
             elif x < bounds['y_range']:
                 quick_options('y_range', self, self.y_log)
         self._canvas.draw()
コード例 #6
0
 def test_accept(self, quick_line_options_view):
     quick_line_options_view.return_value = self.view
     shown = PropertyMock(return_value=True)
     type(self.view).shown = shown
     legend = PropertyMock(return_value=True)
     type(self.view).legend = legend
     error_bar = PropertyMock(return_value=True)
     type(self.view).error_bar = error_bar
     self.view.exec_ = MagicMock(return_value=True)
     quick_options(self.target, self.model)
コード例 #7
0
 def test_accept_legend_shown(self, quick_line_options_view):
     quick_line_options_view.return_value = self.view
     shown = PropertyMock(return_value=False)
     type(self.view).shown = shown
     legend = PropertyMock(return_value=False)
     type(self.view).legend = legend
     self.view.exec_ = MagicMock(return_value=True)
     quick_options(self.target, self.model)
     values = {
         'color': 1,
         'style': 2,
         'width': 3,
         'marker': 4,
         'label': 5,
         'shown': False,
         'legend': False,
         'error_bar': True
     }
     self.model.set_line_options.assert_called_once_with(
         self.target, values)
コード例 #8
0
    def test_line_cut(self, qlo_mock):
        plot_figure = MagicMock()
        window = MagicMock()
        plot_figure.window = window
        canvas = MagicMock()
        window.canvas = canvas
        cut_plotter = MagicMock()
        model = CutPlot(plot_figure, cut_plotter, 'workspace')
        qlo_mock, target = setup_line_values(qlo_mock)

        container = ErrorbarContainer([target], has_yerr=True, label='label1')
        model._lines[target] = container
        container_mock = MagicMock()
        container_mock.containers = [container]
        canvas.figure.gca = MagicMock(return_value=container_mock)

        quick_options(target, model)
        # check view is called with existing line parameters
        qlo_mock.assert_called_with({
            'shown': True,
            'color': '#ff0000',
            'label': u'label1',
            'style': '-',
            'width': '3',
            'marker': 'o',
            'legend': True,
            'error_bar': False
        })
        # check model is updated with parameters from view
        self.assertDictEqual(
            model.get_line_options(target), {
                'shown': True,
                'color': '#0000ff',
                'label': u'label2',
                'style': '--',
                'width': '5',
                'marker': '.',
                'legend': True,
                'error_bar': False
            })
コード例 #9
0
 def test_axis(self, axis_options_mock):
     target = "x_axis"
     quick_options(target, self.model)
     axis_options_mock.assert_called_once_with(target, self.model, None)
コード例 #10
0
 def test_line(self, line_options_mock):
     target = Line2D([], [], 3, '-', 'red', 'o', label='label1')
     quick_options(target, self.model)
     line_options_mock.assert_called_once_with(target, self.model)
コード例 #11
0
 def test_label(self, label_options_mock):
     target = Mock(spec=text.Text)
     quick_options(target, self.model)
     label_options_mock.assert_called_once_with(target)
コード例 #12
0
 def test_reject(self, quick_line_options_view):
     quick_line_options_view.return_value = self.view
     self.view.exec_ = MagicMock(return_value=False)
     quick_options(self.target, self.model)
     self.model.set_line_options_by_index.assert_not_called()
コード例 #13
0
 def test_accept(self, quick_label_options_view):
     quick_label_options_view.return_value = self.view
     self.view.exec_ = MagicMock(return_value=True)
     quick_options(self.target, self.model)
     self.target.set_text.assert_called_once_with("label")
コード例 #14
0
 def test_axis_with_grid(self):
     self.target = 'y_range'
     quick_options(self.target, self.model)
     self.assertEquals(self.model.y_grid, True)
コード例 #15
0
ファイル: cut_plot.py プロジェクト: mantidproject/mslice
 def object_clicked(self, target):
     if isinstance(target, Legend):
         return
     quick_options(target, self)
     self.update_legend()
     self._canvas.draw()
コード例 #16
0
ファイル: cut_plot.py プロジェクト: EltayebAhmed/mslice
 def object_clicked(self, target):
     if isinstance(target, Legend):
         return
     quick_options(target, self)
     self.update_legend()
     self._canvas.draw()