Example #1
0
 def test_artists_normalization_state_labeled_correctly_for_non_dist_workspace_with_uneven_spectra(self):
     non_dist_ws = CreateWorkspace(DataX=[10, 20, 25, 30],
                                   DataY=[2, 3, 4, 5],
                                   DataE=[1, 2, 1, 2],
                                   NSpec=1,
                                   Distribution=False,
                                   OutputWorkspace='non_dist_workpace')
     self.ax.plot(non_dist_ws, specNum=1)
     config['graph1d.autodistribution'] = 'Off'
     self.assertTrue(self.ax.tracked_workspaces[non_dist_ws.name()][0].is_normalized)
     del self.ax.tracked_workspaces[non_dist_ws.name()]
Example #2
0
 def test_artists_normalization_labeled_correctly_for_2d_plots_of_non_dist_workspace_and_dist_argument_true(self):
     plot_funcs = ['imshow', 'pcolor', 'pcolormesh', 'pcolorfast', 'tripcolor',
                   'contour', 'contourf', 'tricontour', 'tricontourf']
     non_dist_2d_ws = CreateWorkspace(DataX=[10, 20, 10, 20],
                                      DataY=[2, 3, 2, 3],
                                      DataE=[1, 2, 1, 2],
                                      NSpec=2,
                                      Distribution=False,
                                      OutputWorkspace='non_dist_workpace')
     for plot_func in plot_funcs:
         func = getattr(self.ax, plot_func)
         func(non_dist_2d_ws, distribution=True)
         self.assertFalse(self.ax.tracked_workspaces[non_dist_2d_ws.name()][0].is_normalized)
         del self.ax.tracked_workspaces[non_dist_2d_ws.name()]
Example #3
0
 def test_artists_normalization_state_labeled_correctly_for_2d_plots_of_non_dist_workspace_with_uneven_spectra(self):
     plot_funcs = ['imshow', 'pcolor', 'pcolormesh', 'pcolorfast', 'tripcolor',
                   'contour', 'contourf', 'tricontour', 'tricontourf']
     non_dist_2d_ws = CreateWorkspace(DataX=[10, 20, 25, 30, 10, 20, 25, 30],
                                      DataY=[2, 3, 4, 5, 2, 3, 4, 5],
                                      DataE=[1, 2, 1, 2, 1, 2, 1, 2],
                                      NSpec=2,
                                      Distribution=False,
                                      OutputWorkspace='non_dist_workpace')
     for plot_func in plot_funcs:
         func = getattr(self.ax, plot_func)
         func(non_dist_2d_ws)
         config['graph1d.autodistribution'] = 'Off'
         self.assertTrue(self.ax.tracked_workspaces[non_dist_2d_ws.name()][0].is_normalized)
         del self.ax.tracked_workspaces[non_dist_2d_ws.name()]
Example #4
0
 def test_artists_normalization_labeled_correctly_for_2d_plots_of_non_dist_workspace_and_global_setting_on(self):
     plot_funcs = ['imshow', 'pcolor', 'pcolormesh', 'pcolorfast', 'tripcolor',
                   'contour', 'contourf', 'tricontour', 'tricontourf']
     non_dist_2d_ws = CreateWorkspace(DataX=[10, 20, 10, 20],
                                      DataY=[2, 3, 2, 3],
                                      DataE=[1, 2, 1, 2],
                                      NSpec=2,
                                      Distribution=False,
                                      OutputWorkspace='non_dist_workpace')
     for plot_func in plot_funcs:
         func = getattr(self.ax, plot_func)
         func(non_dist_2d_ws)
         auto_dist = (config['graph1d.autodistribution'] == 'On')
         self.assertEqual(auto_dist, self.ax.tracked_workspaces[non_dist_2d_ws.name()][0].is_normalized)
         del self.ax.tracked_workspaces[non_dist_2d_ws.name()]
    def test_do_simultaneous_fit_adds_multi_input_workspace_to_fit_context(
            self):
        # create function
        single_func = ';name=FlatBackground,$domains=i,A0=0'
        multi_func = 'composite=MultiDomainFunction,NumDeriv=1' + single_func + single_func + ";"
        trial_function = FunctionFactory.createInitialized(multi_func)
        x_data = range(0, 100)
        y_data = [5 + x * x for x in x_data]
        workspace1 = CreateWorkspace(x_data, y_data)
        workspace2 = CreateWorkspace(x_data, y_data)
        parameter_dict = {
            'Function': trial_function,
            'InputWorkspace': [workspace1.name(),
                               workspace2.name()],
            'Minimizer': 'Levenberg-Marquardt',
            'StartX': [0.0] * 2,
            'EndX': [100.0] * 2,
            'EvaluationType': 'CentrePoint'
        }
        self.model.do_simultaneous_fit(parameter_dict, global_parameters=[])

        fit_context = self.model.context.fitting_context
        self.assertEqual(1, len(fit_context))
Example #6
0
 def test_artists_normalization_state_labeled_correctly_for_dist_workspace(self):
     dist_ws = CreateWorkspace(DataX=[10, 20],
                               DataY=[2, 3],
                               DataE=[1, 2],
                               NSpec=1,
                               Distribution=True,
                               OutputWorkspace='dist_workpace')
     self.ax.plot(dist_ws, specNum=1, distribution=False)
     self.ax.plot(dist_ws, specNum=1, distribution=True)
     self.ax.plot(dist_ws, specNum=1)
     ws_artists = self.ax.tracked_workspaces[dist_ws.name()]
     self.assertTrue(ws_artists[0].is_normalized)
     self.assertTrue(ws_artists[1].is_normalized)
     self.assertTrue(ws_artists[2].is_normalized)
Example #7
0
 def test_plot_is_not_normalized_for_bin_plots(self):
     workspace = CreateWorkspace(DataX=[10, 20],
                                 DataY=[2, 3, 4, 5, 6],
                                 DataE=[1, 2, 1, 2, 1],
                                 NSpec=5,
                                 Distribution=False,
                                 OutputWorkspace='workspace')
     self.ax.plot(workspace, specNum=1, axis=MantidAxType.BIN, distribution=False)
     self.ax.plot(workspace, specNum=1, axis=MantidAxType.BIN, distribution=True)
     self.ax.plot(workspace, specNum=1, axis=MantidAxType.BIN)
     ws_artists = self.ax.tracked_workspaces[workspace.name()]
     self.assertFalse(ws_artists[0].is_normalized)
     self.assertFalse(ws_artists[1].is_normalized)
     self.assertFalse(ws_artists[2].is_normalized)
Example #8
0
    def test_artists_normalization_state_labeled_correctly_for_non_dist_workspace(
            self):
        non_dist_ws = CreateWorkspace(DataX=[10, 20],
                                      DataY=[2, 3],
                                      DataE=[1, 2],
                                      NSpec=1,
                                      Distribution=False,
                                      OutputWorkspace='non_dist_workpace')
        self.ax.plot(non_dist_ws, specNum=1, distribution=False)
        self.assertTrue(
            self.ax.tracked_workspaces[non_dist_ws.name()][0].is_normalized)
        del self.ax.tracked_workspaces[non_dist_ws.name()]

        self.ax.errorbar(non_dist_ws, specNum=1, distribution=True)
        self.assertFalse(
            self.ax.tracked_workspaces[non_dist_ws.name()][0].is_normalized)
        del self.ax.tracked_workspaces[non_dist_ws.name()]

        auto_dist = (config['graph1d.autodistribution'] == 'On')
        self.ax.plot(non_dist_ws, specNum=1)
        self.assertEqual(
            auto_dist,
            self.ax.tracked_workspaces[non_dist_ws.name()][0].is_normalized)
        del self.ax.tracked_workspaces[non_dist_ws.name()]
Example #9
0
    def test_do_simultaneous_fit_adds_single_input_workspace_to_fit_context_with_globals(self):
        trial_function = FunctionFactory.createInitialized('name = Quadratic, A0 = 0, A1 = 0, A2 = 0')
        x_data = range(0, 100)
        y_data = [5 + x * x for x in x_data]
        workspace = CreateWorkspace(x_data, y_data)
        parameter_dict = {'Function': trial_function, 'InputWorkspace': [workspace.name()],
                          'Minimizer': 'Levenberg-Marquardt',
                          'StartX': [0.0], 'EndX': [100.0], 'EvaluationType': 'CentrePoint',
                          'FitGroupName': 'SimulFit'}
        global_parameters = ['A0']
        self.model.do_simultaneous_fit(parameter_dict, global_parameters)

        fit_context = self.model.context.fitting_context
        self.assertEqual(1, len(fit_context))
        self.assertEqual(global_parameters, fit_context.fit_list[0].parameters.global_parameters)
    def setUpClass(cls):
        cls.ws_widget = WorkspaceWidget(QMainWindow())
        mat_ws = CreateSampleWorkspace()
        table_ws = CreateEmptyTableWorkspace()
        group_ws = GroupWorkspaces([mat_ws, table_ws])
        single_val_ws = CreateSingleValuedWorkspace(5, 6)

        # Create ragged workspace
        ws2d_ragged = CreateWorkspace(DataX=[10, 20, 30],
                                      DataY=[1, 2, 3],
                                      NSpec=1,
                                      OutputWorkspace='Ragged')
        temp = CreateWorkspace(DataX=[15, 25, 35, 45],
                               DataY=[1, 2, 3, 4],
                               NSpec=1)
        ConjoinWorkspaces(ws2d_ragged, temp, CheckOverlapping=False)
        ws2d_ragged = AnalysisDataService.retrieve('Ragged')

        cls.w_spaces = [mat_ws, table_ws, group_ws, single_val_ws]
        cls.ws_names = ['MatWS', 'TableWS', 'GroupWS', 'SingleValWS']
        # create md workspace
        md_ws = CreateMDHistoWorkspace(SignalInput='1,2,3,4,2,1',
                                       ErrorInput='1,1,1,1,1,1',
                                       Dimensionality=3,
                                       Extents='-1,1,-1,1,0.5,6.5',
                                       NumberOfBins='1,1,6',
                                       Names='x,y,|Q|',
                                       Units='mm,km,AA^-1',
                                       OutputWorkspace='MDHistoWS1D')
        # self.w_spaces = [mat_ws, table_ws, group_ws, single_val_ws, md_ws]
        # self.ws_names = ['MatWS', 'TableWS', 'GroupWS', 'SingleValWS', 'MDHistoWS1D']
        for ws_name, ws in zip(cls.ws_names, cls.w_spaces):
            cls.ws_widget._ads.add(ws_name, ws)
        cls.ws_names.append(md_ws.name())
        cls.w_spaces.append(md_ws)
        cls.ws_names.append(ws2d_ragged.name())
        cls.w_spaces.append(ws2d_ragged)