def test_categorizing_of_uncategorized_plot(self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock(), mock.Mock()]
        fig1_mock_manager = mock.Mock()
        # This manager is used to compare the relative order of calls of two differebc functions
        fig1_mock_manager.attach_mock(mock_figures[0].flag_as_kept, 'fig1_kept')
        fig1_mock_manager.attach_mock(mock_figures[0].flag_as_current, 'fig1_current')
        mock_figure_class.side_effect = mock_figures
        cat1 = '1d'
        cat2 = '2d'
        cat1_get_active_figure = set_category(cat1)(GlobalFigureManager.get_active_figure)
        cat2_get_active_figure = set_category(cat2)(GlobalFigureManager.get_active_figure)

        # test is an arbitrary method just to make sure the correct figures are returned

        cat1_get_active_figure().test(1)  # create a figure of category 1
        cat2_get_active_figure().test(2)  # create a figure of category 2
        GlobalFigureManager.set_figure_as_kept(2) # now there is no active figure

        GlobalFigureManager.get_active_figure().test(3) # create an uncategorized figure
        cat1_get_active_figure().test(4) # the previously uncategorized figure should now be categorized as cat1

        mock_figures[0].test.assert_has_calls([call(1)])
        mock_figures[1].test.assert_has_calls([call(2)])
        mock_figures[2].test.assert_has_calls([call(3), call(4)])

        self.assertTrue(fig1_mock_manager.mock_calls[-1] == call.fig1_kept())  # assert final status of fig1 is kept
        self.assertTrue(GlobalFigureManager._active_figure == 3)
    def test_create_single_unclassified_plot_success(self, mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures

        GlobalFigureManager.get_figure_number()
        self.assertTrue(1 in GlobalFigureManager.all_figure_numbers()) #Check that a new figure with number=1 was created
        self.assertRaises(KeyError, GlobalFigureManager.get_category, 1) #Check that figure has no category
        self.assertTrue(GlobalFigureManager.get_active_figure() == mock_figures[0]) # Check that it is set as the active figure
Esempio n. 3
0
def pcolormesh(axes, workspace, *args, **kwargs):
    """
    Same as the CLI PlotSlice but returns the relevant axes object.
    """
    from mslice.app.presenters import get_slice_plotter_presenter, cli_slice_plotter_presenter
    _check_workspace_name(workspace)
    workspace = get_workspace_handle(workspace)
    _check_workspace_type(workspace, HistogramWorkspace)

    # slice cache needed from main slice plotter presenter
    if is_gui() and GlobalFigureManager.get_active_figure().plot_handler is not None:
        cli_slice_plotter_presenter._slice_cache = app.MAIN_WINDOW.slice_plotter_presenter._slice_cache
    else:
        # Needed so the figure manager knows about the slice plot handler
        create_slice_figure(workspace.name[2:], get_slice_plotter_presenter())

    slice_cache = get_slice_plotter_presenter().get_slice_cache(workspace)

    intensity = kwargs.pop('intensity', None)
    temperature = kwargs.pop('temperature', None)

    if temperature is not None:
        get_slice_plotter_presenter().set_sample_temperature(workspace.name[2:], temperature)

    if intensity is not None and intensity != 's(q,e)':
        workspace = getattr(slice_cache, _intensity_to_workspace[intensity])
        plot_window = GlobalFigureManager.get_active_figure().window
        plot_handler = GlobalFigureManager.get_active_figure().plot_handler
        intensity_action = getattr(plot_window, _intensity_to_action[intensity])
        plot_handler.set_intensity(intensity_action)
        intensity_action.setChecked(True)

        # Set intensity properties for generated script to use
        if not is_gui():
            for key, value in _function_to_intensity.items():
                if value == intensity:
                    intensity_method = key
                    break
            plot_handler.intensity = True
            plot_handler.intensity_method = intensity_method
            plot_handler.temp = temperature
            plot_handler.temp_dependent = True if temperature is not None else False
            plot_handler._slice_plotter_presenter._slice_cache[plot_handler.ws_name].colourmap = kwargs.get('cmap')

    if not workspace.is_PSD and not slice_cache.rotated:
        workspace = Transpose(OutputWorkspace=workspace.name, InputWorkspace=workspace, store=False)
    plotfunctions.pcolormesh(axes, workspace.raw_ws, *args, **kwargs)
    axes.set_title(workspace.name[2:], picker=SLICE_PICKER_TOL_PTS)
    x_axis = slice_cache.energy_axis if slice_cache.rotated else slice_cache.momentum_axis
    y_axis = slice_cache.momentum_axis if slice_cache.rotated else slice_cache.energy_axis
    axes.get_xaxis().set_units(x_axis.units)
    axes.get_yaxis().set_units(y_axis.units)
    # labels
    axes.set_xlabel(get_display_name(x_axis), picker=SLICE_PICKER_TOL_PTS)
    axes.set_ylabel(get_display_name(y_axis), picker=SLICE_PICKER_TOL_PTS)
    axes.set_xlim(x_axis.start, x_axis.end)
    axes.set_ylim(y_axis.start, y_axis.end)
    return axes.collections[0]  # Quadmesh object
    def test_create_multiple_unclassified_figures(self, mock_figure_class):
        """Test that n calls to GlobalFigureManager create n unclassified _figures numbered 1 to n """
        n = 10  # number of unclassfied _figures to be created
        mock_figures = [mock.Mock() for i in range(n)]
        mock_figure_class.side_effect = mock_figures

        for i in range(n):
            GlobalFigureManager.get_figure_number() # Create a new figure
        for i in range(1, n+1):
            self.assertTrue(i in GlobalFigureManager.all_figure_numbers()) #Check that a new figure with number=i was created
            self.assertRaises(KeyError, GlobalFigureManager.get_category, i) #Check that figure has no category
 def test_create_single_categorised_figure(self,mock_figure_class):
     mock_figures = [mock.Mock()]
     mock_figure_class.side_effect = mock_figures
     category = '1d'
     # The following line is equivalent to applying the decorator setcategory with the parameter category
     # to function GlobalFigureManager.get_active_figure
     categorised_get_active_figure = set_category(category)(GlobalFigureManager.get_active_figure)
     fig = categorised_get_active_figure()
     self.assertTrue(fig == mock_figures[0]) # Assert Figure object came from right place
     self.assertTrue(GlobalFigureManager.get_category(1) == category)
     self.assertTrue(GlobalFigureManager.get_active_figure() == mock_figures[0]) # Check that it is set as the active figure
Esempio n. 6
0
    def test_close_non_existant_window_fail(self, mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        # Get a figure
        fig1 = GlobalFigureManager.get_active_figure()
        # check that getting the active window doesnt bring up a new one
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig1)
        self.assertRaises(KeyError, GlobalFigureManager.figure_closed, 2)
        fig2 = GlobalFigureManager.get_active_figure()

        self.assertTrue(fig1 == mock_figures[0])
        self.assertTrue(fig2 == mock_figures[0])
Esempio n. 7
0
    def test_close_only_window(self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        # Get a figure
        fig1 = GlobalFigureManager.get_active_figure()
        # check that getting the active window doesnt bring up a new one
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig1)
        GlobalFigureManager.figure_closed(1)
        fig2 = GlobalFigureManager.get_active_figure()

        self.assertTrue(fig1 == mock_figures[0])
        self.assertTrue(fig2 == mock_figures[1])
    def test_close_non_existant_window_fail(self,mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        # Get a figure
        fig1 = GlobalFigureManager.get_active_figure()
        # check that getting the active window doesnt bring up a new one
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig1)
        self.assertRaises(KeyError, GlobalFigureManager.figure_closed, 2)
        fig2 = GlobalFigureManager.get_active_figure()

        self.assertTrue(fig1 == mock_figures[0])
        self.assertTrue(fig2 == mock_figures[0])
    def test_close_only_window(self,mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        # Get a figure
        fig1 = GlobalFigureManager.get_active_figure()
        # check that getting the active window doesnt bring up a new one
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig1)
        GlobalFigureManager.figure_closed(1)
        fig2 = GlobalFigureManager.get_active_figure()

        self.assertTrue(fig1 == mock_figures[0])
        self.assertTrue(fig2 == mock_figures[1])
Esempio n. 10
0
    def test_create_single_unclassified_plot_success(self, mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures

        GlobalFigureManager.get_figure_number()
        self.assertTrue(1 in GlobalFigureManager.all_figure_numbers()
                        )  #Check that a new figure with number=1 was created
        self.assertRaises(KeyError, GlobalFigureManager.get_category,
                          1)  #Check that figure has no category
        self.assertTrue(
            GlobalFigureManager.get_active_figure() ==
            mock_figures[0])  # Check that it is set as the active figure
Esempio n. 11
0
    def test_create_multiple_unclassified_figures(self, mock_figure_class):
        """Test that n calls to GlobalFigureManager create n unclassified _figures numbered 1 to n """
        n = 10  # number of unclassfied _figures to be created
        mock_figures = [mock.Mock() for i in range(n)]
        mock_figure_class.side_effect = mock_figures

        for i in range(n):
            GlobalFigureManager.get_figure_number()  # Create a new figure
        for i in range(1, n + 1):
            self.assertTrue(i in GlobalFigureManager.all_figure_numbers(
            ))  #Check that a new figure with number=i was created
            self.assertRaises(KeyError, GlobalFigureManager.get_category,
                              i)  #Check that figure has no category
Esempio n. 12
0
    def test_create_categorised_figure_then_uncategorised_figure(self,mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        category = '1d'
        categorised_get_active_figure = set_category(category)(GlobalFigureManager.get_active_figure)

        fig1 = categorised_get_active_figure()
        fig2 = GlobalFigureManager.get_figure_number()
        fig1_number = GlobalFigureManager.number_of_figure(fig1)
        fig2_number = GlobalFigureManager.number_of_figure(fig2)
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig2)
        self.assertTrue(GlobalFigureManager.get_category(fig1_number) == category)
        self.assertRaises(KeyError, GlobalFigureManager.get_category, fig2_number)
        self.assertTrue( fig1_number == 1 and fig2_number == 2)
Esempio n. 13
0
def Show():
    """
    Show all figures and start the event loop if necessary
    """
    managers = GlobalFigureManager.get_all_fig_managers()
    if not managers:
        return

    for manager in managers:
        manager.show()

    # Hack: determine at runtime whether we are
    # inside ipython in pylab mode.
    from matplotlib import pyplot

    try:
        ipython_pylab = not pyplot.show._needmain
        # IPython versions >= 0.10 tack the _needmain
        # attribute onto pyplot.show, and always set
        # it to False, when in %pylab mode.
        ipython_pylab = ipython_pylab and mpl.get_backend() != 'WebAgg'
        # TODO: The above is a hack to get the WebAgg backend
        # working with ipython's `%pylab` mode until proper
        # integration is implemented.
    except AttributeError:
        ipython_pylab = False

    # Leave the following as a separate step in case we
    # want to control this behavior with an rcParam.
    if ipython_pylab:
        return

    if not mpl.is_interactive() or mpl.get_backend() == 'WebAgg':
        QAppThreadCall(mainloop)()
Esempio n. 14
0
 def test_create_single_categorised_figure(self, mock_figure_class):
     mock_figures = [mock.Mock()]
     mock_figure_class.side_effect = mock_figures
     category = '1d'
     # The following line is equivalent to applying the decorator setcategory with the parameter category
     # to function GlobalFigureManager.get_active_figure
     categorised_get_active_figure = set_category(category)(
         GlobalFigureManager.get_active_figure)
     fig = categorised_get_active_figure()
     self.assertTrue(
         fig ==
         mock_figures[0])  # Assert Figure object came from right place
     self.assertTrue(GlobalFigureManager.get_category(1) == category)
     self.assertTrue(
         GlobalFigureManager.get_active_figure() ==
         mock_figures[0])  # Check that it is set as the active figure
Esempio n. 15
0
def Show():
    """
    Show all figures and start the event loop if necessary
    """
    managers = GlobalFigureManager.get_all_fig_managers()
    if not managers:
        return

    for manager in managers:
        manager.show()

    # Hack: determine at runtime whether we are
    # inside ipython in pylab mode.
    from matplotlib import pyplot

    try:
        ipython_pylab = not pyplot.show._needmain
        # IPython versions >= 0.10 tack the _needmain
        # attribute onto pyplot.show, and always set
        # it to False, when in %pylab mode.
        ipython_pylab = ipython_pylab and mpl.get_backend() != 'WebAgg'
        # TODO: The above is a hack to get the WebAgg backend
        # working with ipython's `%pylab` mode until proper
        # integration is implemented.
    except AttributeError:
        ipython_pylab = False

    # Leave the following as a separate step in case we
    # want to control this behavior with an rcParam.
    if ipython_pylab:
        return

    if not mpl.is_interactive() or mpl.get_backend() == 'WebAgg':
        QAppThreadCall(mainloop)()
Esempio n. 16
0
    def test_create_categorised_figure_then_uncategorised_figure(
            self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        category = '1d'
        categorised_get_active_figure = set_category(category)(
            GlobalFigureManager.get_active_figure)

        fig1 = categorised_get_active_figure()
        fig2 = GlobalFigureManager.get_figure_number()
        fig1_number = GlobalFigureManager.number_of_figure(fig1)
        fig2_number = GlobalFigureManager.number_of_figure(fig2)
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig2)
        self.assertTrue(
            GlobalFigureManager.get_category(fig1_number) == category)
        self.assertRaises(KeyError, GlobalFigureManager.get_category,
                          fig2_number)
        self.assertTrue(fig1_number == 1 and fig2_number == 2)
Esempio n. 17
0
    def grid(self, b=None, which='major', axis='both', **kwargs):
        Axes.grid(self, b, which, axis, **kwargs)

        plot_handler = GlobalFigureManager.get_active_figure().plot_handler
        if plot_handler is not None and not is_gui():
            if axis == 'x':
                plot_handler.manager._xgrid = b
            elif axis == 'y':
                plot_handler.manager._ygrid = b
Esempio n. 18
0
def SymmetriseSQE(figure_number):
    """
        Converts to the double differential cross-section d2sigma/dOmega.dE  on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """
    from mslice.plotting.plot_window.slice_plot import SlicePlot
    plot_handler = GlobalFigureManager.get_figure_by_number(figure_number).plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_symmetrised_sqe.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 19
0
def ConvertToGDOS(figure_number):
    """
        Converts to symmetrised S(Q,E) (w.r.t. energy using temperature Boltzmann factor) on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """
    from mslice.plotting.plot_window.slice_plot import SlicePlot
    plot_handler = GlobalFigureManager.get_figure_by_number(figure_number).plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_gdos.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 20
0
def ConvertToChiMag(figure_number):
    """
        Converts to the magnetic dynamical susceptibility Chi''(Q,E magnetic on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """
    from mslice.plotting.plot_window.slice_plot import SlicePlot
    plot_handler = GlobalFigureManager.get_figure_by_number(figure_number).plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_chi_qe_magnetic.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 21
0
    def test_make_current_with_single_category(self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        # These manager is used to compare the relative order of calls of two different functions
        mock_managers = [mock.Mock(), mock.Mock()]

        for i in range(len(mock_figures)):
            mock_managers[i].attach_mock(mock_figures[i].flag_as_kept, 'fig_kept')
            mock_managers[i].attach_mock(mock_figures[i].flag_as_current, 'fig_current')
        mock_figure_class.side_effect = mock_figures
        cat1 = '1d'
        cat1_get_active_figure = set_category(cat1)(GlobalFigureManager.get_active_figure)
        # test is an arbitrary method just to make sure the correct figures are returned

        cat1_get_active_figure().test(1)  # create a figure of category 1
        GlobalFigureManager.set_figure_as_kept(1)  # now there is no active figure
        cat1_get_active_figure().test(2)  # this command should go to a new figure

        self.assertTrue(mock_managers[0].mock_calls[-1] == call.fig_kept())     # assert fig1 now displays kept
        self.assertTrue(mock_managers[1].mock_calls[-1] == call.fig_current())  # assert fig2 now displays current

        GlobalFigureManager.set_figure_as_current(1)
        self.assertTrue(mock_managers[0].mock_calls[-1] == call.fig_current())     # assert fig1 now displays current
        self.assertTrue(mock_managers[1].mock_calls[-1] == call.fig_kept())        # assert fig2 now displays kept

        cat1_get_active_figure().test(3)                # This should go to fig1
        GlobalFigureManager.get_active_figure().test(4)       # This should go to fig1 as well

        mock_figures[0].test.assert_has_calls([call(1), call(3), call(4)])
        mock_figures[1].test.assert_has_calls([call(2)])

        self.assertTrue(GlobalFigureManager._active_figure == 1)
Esempio n. 22
0
def ConvertToChiMag(figure_number):
    """
        Converts to the magnetic dynamical susceptibility Chi''(Q,E magnetic on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """

    plot_handler = GlobalFigureManager.get_figure_by_number(
        figure_number)._plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_chi_qe_magnetic.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 23
0
def SymmetriseSQE(figure_number):
    """
        Converts to the double differential cross-section d2sigma/dOmega.dE  on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """

    plot_handler = GlobalFigureManager.get_figure_by_number(
        figure_number)._plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_symmetrised_sqe.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 24
0
def ConvertToGDOS(figure_number):
    """
        Converts to symmetrised S(Q,E) (w.r.t. energy using temperature Boltzmann factor) on Slice Plot
        :param figure_number: The slice plot figure number returned when the plot was made.
        :return:
        """

    plot_handler = GlobalFigureManager.get_figure_by_number(
        figure_number)._plot_handler
    if isinstance(plot_handler, SlicePlot):
        plot_handler.plot_window.action_gdos.trigger()
    else:
        print('This function cannot be used on a Cut')
Esempio n. 25
0
 def set_waterfall(self, isWaterfall=True, x_offset=None, y_offset=None):
     """ Change the plot to/from a waterfall """
     from mslice.plotting.plot_window.cut_plot import CutPlot
     plot_handler = GlobalFigureManager.get_active_figure().plot_handler
     if isinstance(plot_handler, CutPlot):
         plot_handler.waterfall = isWaterfall
         if x_offset is not None:
             plot_handler.waterfall_x = x_offset
         if y_offset is not None:
             plot_handler.waterfall_y = y_offset
         plot_handler.toggle_waterfall()
     else:
         raise RuntimeError('Waterfall plots may only be applied to cuts')
Esempio n. 26
0
    def test_categorizing_of_uncategorized_plot(self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock(), mock.Mock()]
        fig1_mock_manager = mock.Mock()
        # This manager is used to compare the relative order of calls of two differebc functions
        fig1_mock_manager.attach_mock(mock_figures[0].flag_as_kept,
                                      'fig1_kept')
        fig1_mock_manager.attach_mock(mock_figures[0].flag_as_current,
                                      'fig1_current')
        mock_figure_class.side_effect = mock_figures
        cat1 = '1d'
        cat2 = '2d'
        cat1_get_active_figure = set_category(cat1)(
            GlobalFigureManager.get_active_figure)
        cat2_get_active_figure = set_category(cat2)(
            GlobalFigureManager.get_active_figure)

        # test is an arbitrary method just to make sure the correct figures are returned

        cat1_get_active_figure().test(1)  # create a figure of category 1
        cat2_get_active_figure().test(2)  # create a figure of category 2
        GlobalFigureManager.set_figure_as_kept(
            2)  # now there is no active figure

        GlobalFigureManager.get_active_figure().test(
            3)  # create an uncategorized figure
        cat1_get_active_figure().test(
            4
        )  # the previously uncategorized figure should now be categorized as cat1

        mock_figures[0].test.assert_has_calls([call(1)])
        mock_figures[1].test.assert_has_calls([call(2)])
        mock_figures[2].test.assert_has_calls([call(3), call(4)])

        self.assertTrue(
            fig1_mock_manager.mock_calls[-1] ==
            call.fig1_kept())  # assert final status of fig1 is kept
        self.assertTrue(GlobalFigureManager._active_figure == 3)
Esempio n. 27
0
    def recoil(self, workspace, element=None, rmm=None):
        from mslice.app.presenters import get_slice_plotter_presenter
        _check_workspace_name(workspace)
        workspace = get_workspace_handle(workspace)
        _check_workspace_type(workspace, HistogramWorkspace)

        key = _get_overplot_key(element, rmm)

        if rmm is not None:
            plot_handler = GlobalFigureManager.get_active_figure().plot_handler
            plot_handler._arb_nuclei_rmm = rmm

        get_slice_plotter_presenter().add_overplot_line(workspace.name, key, recoil=True, cif=None)

        _update_overplot_checklist(key)
        _update_legend()
Esempio n. 28
0
    def test_make_current_with_single_category(self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        # These manager is used to compare the relative order of calls of two different functions
        mock_managers = [mock.Mock(), mock.Mock()]

        for i in range(len(mock_figures)):
            mock_managers[i].attach_mock(mock_figures[i].flag_as_kept,
                                         'fig_kept')
            mock_managers[i].attach_mock(mock_figures[i].flag_as_current,
                                         'fig_current')
        mock_figure_class.side_effect = mock_figures
        cat1 = '1d'
        cat1_get_active_figure = set_category(cat1)(
            GlobalFigureManager.get_active_figure)
        # test is an arbitrary method just to make sure the correct figures are returned

        cat1_get_active_figure().test(1)  # create a figure of category 1
        GlobalFigureManager.set_figure_as_kept(
            1)  # now there is no active figure
        cat1_get_active_figure().test(
            2)  # this command should go to a new figure

        self.assertTrue(mock_managers[0].mock_calls[-1] ==
                        call.fig_kept())  # assert fig1 now displays kept
        self.assertTrue(mock_managers[1].mock_calls[-1] ==
                        call.fig_current())  # assert fig2 now displays current

        GlobalFigureManager.set_figure_as_current(1)
        self.assertTrue(mock_managers[0].mock_calls[-1] ==
                        call.fig_current())  # assert fig1 now displays current
        self.assertTrue(mock_managers[1].mock_calls[-1] ==
                        call.fig_kept())  # assert fig2 now displays kept

        cat1_get_active_figure().test(3)  # This should go to fig1
        GlobalFigureManager.get_active_figure().test(
            4)  # This should go to fig1 as well

        mock_figures[0].test.assert_has_calls([call(1), call(3), call(4)])
        mock_figures[1].test.assert_has_calls([call(2)])

        self.assertTrue(GlobalFigureManager._active_figure == 1)
Esempio n. 29
0
def GenerateScript(InputWorkspace, filename):
    from mslice.scripting import generate_script
    _check_workspace_name(InputWorkspace)
    workspace_name = get_workspace_handle(InputWorkspace).name[2:]
    plot_handler = GlobalFigureManager.get_active_figure().plot_handler
    generate_script(ws_name=workspace_name, filename=filename, plot_handler=plot_handler)
Esempio n. 30
0
def cut_figure_exists():
    return GlobalFigureManager.active_cut_figure_exists()
Esempio n. 31
0
def MakeCurrent(figure_number=None):
    GlobalFigureManager.set_figure_as_current(figure_number)
Esempio n. 32
0
 def setUp(self):
     GlobalFigureManager.reset()
Esempio n. 33
0
def KeepFigure(figure_number=None):
    GlobalFigureManager.set_figure_as_kept(figure_number)
Esempio n. 34
0
def cut_figure_exists():
    return GlobalFigureManager.active_cut_figure_exists()
Esempio n. 35
0
 def setUp(self):
     GlobalFigureManager.reset()
Esempio n. 36
0
def KeepFigure(figure_number=None):
    GlobalFigureManager.set_figure_as_kept(figure_number)
Esempio n. 37
0
def MakeCurrent(figure_number=None):
    GlobalFigureManager.set_figure_as_current(figure_number)