def setUp(self):
        self.context = setup_context(True)

        self.context.data_context.instrument = 'MUSR'

        self.context.gui_context.update({'RebinType': 'None'})

        self.view = fft_view_new.FFTView()
        self.model1 = fft_model.FFTModel()
        self.model = fft_model.FFTWrapper

        self.presenter = fft_presenter_new.FFTPresenter(
            self.view, self.model, self.context)

        file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
        ws, run, filename, _ = load_utils.load_workspace_from_filename(file_path)
        self.context.data_context._loaded_data.remove_data(run=run)
        self.context.data_context._loaded_data.add_data(run=[run], workspace=ws, filename=filename, instrument='MUSR')
        self.context.data_context.current_runs = [[22725]]

        self.context.update_current_data()
        test_pair = MuonPair(EXAMPLE_PAIR, 'top', 'bottom', alpha=0.75)
        self.context.group_pair_context.add_pair(pair=test_pair)
        self.context.show_all_groups()
        self.context.show_all_pairs()
        self.context.group_pair_context._selected_groups = GROUP_LIST
        self.context.group_pair_context._selected_pairs = [EXAMPLE_PAIR]

        self.view.warning_popup = mock.MagicMock()
    def setUp(self):
        self.context = setup_context(True)
        self.context.data_context.instrument = 'MUSR'
        self.context.gui_context.update({'RebinType': 'None'})

        # View
        self.view = mock.create_autospec(maxent_view.MaxEntView, spec_set=True)
        # signals
        # needed for connect in presenter
        self.view.maxEntButtonSignal = mock.Mock()
        self.view.cancelSignal = mock.Mock()

        # Default Values
        type(self.view).get_run = mock.PropertyMock(return_value="2435")
        type(self.view).num_periods = mock.PropertyMock(return_value=1)
        type(self.view).get_period = mock.PropertyMock(return_value="1")

        self.view.phase_table = "Construct"
        self.view.num_points = 2048
        self.view.inner_iterations = 10
        self.view.outer_iterations = 10
        self.view.double_pulse = False
        self.view.lagrange_multiplier = 1
        self.view.maximum_field = 1000
        self.view.maximum_entropy_constant = 0.1
        self.view.fit_dead_times = False

        self.context.data_context.num_periods = mock.Mock(return_value=1)

        # Presenter
        self.presenter = maxent_presenter.MaxEntPresenter(self.view, self.context)

        # make thread
        self.thread = mock.create_autospec(thread_model.ThreadModel)
Example #3
0
    def test_get_pair_phasequad_name(self):
        AnalysisDataService.clear()
        ConfigService['MantidOptions.InvisibleWorkspaces'] = 'True'
        filepath = FileFinder.findRuns('EMU00019489.nxs')[0]

        load_result, run_number, filename, psi_data = load_workspace_from_filename(
            filepath)

        context = setup_context()
        context.gui_context.update({'RebinType': 'None'})
        context.data_context.instrument = 'EMU'

        context.data_context._loaded_data.add_data(workspace=load_result,
                                                   run=[run_number],
                                                   filename=filename,
                                                   instrument='EMU')
        context.data_context.current_runs = [[run_number]]
        context.data_context.update_current_data()

        self.assertEqual(
            "EMU19489; PhaseQuad; test_Re; MA",
            get_pair_phasequad_name(context, "test_Re", "19489", False))
        self.assertEqual(
            "EMU19489; PhaseQuad; test_Re; Rebin; MA",
            get_pair_phasequad_name(context, "test_Re", "19489", True))
    def setUp(self):
        self.context = setup_context(True)

        self.context.data_context.instrument = 'MUSR'

        self.context.gui_context.update({'RebinType': 'None'})
        self.model = maxent_model.MaxEntModel()

        self.view = maxent_view_new.MaxEntView()

        self.presenter = maxent_presenter_new.MaxEntPresenter(
            self.view, self.context)

        file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
        ws, run, filename, _ = load_utils.load_workspace_from_filename(
            file_path)
        self.context.data_context._loaded_data.remove_data(run=run)
        self.context.data_context._loaded_data.add_data(run=[run],
                                                        workspace=ws,
                                                        filename=filename,
                                                        instrument='MUSR')
        self.context.data_context.current_runs = [[22725]]

        self.context.update_current_data()
        test_pair = MuonPair('test_pair', 'top', 'bottom', alpha=0.75)
        self.context.group_pair_context.add_pair(pair=test_pair)

        self.view.warning_popup = mock.MagicMock()
Example #5
0
    def setUp(self):
        self.context = setup_context()
        self.model = mock.Mock(spec=PlotTimeFitPaneModel)
        self.model.name = "data"
        # manually add pane
        self.context.plot_panes_context.add_pane(self.model.name)

        self.view = mock.Mock(spec=BasePaneView)
        self.view.warning_popup = mock.MagicMock()
        self.view.disable_plot_raw_option()
        self.view.hide_plot_type = mock.Mock()
        self.view.hide_plot_raw = mock.Mock()
        self.view.hide_tiled_by = mock.Mock()

        self.figure_presenter = mock.Mock(
            spec=PlottingCanvasPresenterInterface)
        self.figure_presenter.set_errors = mock.Mock()
        self.figure_presenter.set_plot_range = mock.Mock()

        self.presenter = PlotModelFitPanePresenter(
            view=self.view,
            model=self.model,
            context=self.context,
            fitting_context=self.context.fitting_context,
            figure_presenter=self.figure_presenter)
Example #6
0
    def setUp(self):
        AnalysisDataService.clear()
        ConfigService['MantidOptions.InvisibleWorkspaces'] = 'True'
        self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0]

        self.load_result, self.run_number, self.filename, psi_data = load_workspace_from_filename(
            self.filepath)
        self.assert_(not psi_data)

        self.context = setup_context(True)
        self.context.gui_context.update({'RebinType': 'None'})
        self.loaded_data = self.context.data_context._loaded_data
        self.data_context = self.context.data_context
        self.gui_context = self.context.gui_context
        self.group_pair_context = self.context.group_pair_context
        self.data_context.instrument = 'EMU'

        self.loaded_data.add_data(workspace=self.load_result,
                                  run=[self.run_number],
                                  filename=self.filename,
                                  instrument='EMU')
        self.data_context.current_runs = [[self.run_number]]
        self.data_context.update_current_data()
        self.group_pair_context.reset_group_and_pairs_to_default(
            self.load_result['OutputWorkspace'][0].workspace, 'EMU', '', 1)
Example #7
0
 def setUp(self):
     self.current_runs = [[22725]]
     self.context = setup_context(True)
     self.context.get_names_of_workspaces_to_fit = mock.MagicMock(
         return_value=['MUSR22725; Group; fwd; Asymmetry; #1'])
     self.view = WorkspaceSelectorView(self.current_runs, 'MUSR', [], True, None, self.context)
     self.view.list_selector_presenter = mock.MagicMock()
     self.context.get_names_of_workspaces_to_fit.reset_mock()
 def setUp(self):
     context = setup_context()
     self.model = ModelFittingModel(context, context.model_fitting_context)
     self.result_table_names = ["Result1", "Result2"]
     self.dataset_names = ["workspace_name_A0", "workspace_name_A1", "A0_A1"]
     self.fit_function1 = FunctionFactory.createFunction("FlatBackground")
     self.fit_function2 = FunctionFactory.createFunction("LinearBackground")
     self.single_fit_functions = [self.fit_function1.clone(), self.fit_function1.clone(), self.fit_function2.clone()]
 def setUp(self):
     self.context = setup_context()
     self.context.data_context.current_runs = [[62260]]
     self.context.data_context.instrument = 'MUSR'
     self.widget = FittingTabWidget(self.context, parent=None)
     self.presenter = self.widget.fitting_tab_presenter
     self.view = self.widget.fitting_tab_view
     self.presenter.model = mock.MagicMock()
Example #10
0
 def setUp(self):
     context = setup_context()
     self.model = GeneralFittingModel(context, context.fitting_context)
     self.dataset_names = ["Name1", "Name2"]
     self.fit_function = FunctionFactory.createFunction("FlatBackground")
     self.single_fit_functions = [self.fit_function.clone(), self.fit_function.clone()]
     self.simultaneous_fit_function = FunctionFactory.createInitializedMultiDomainFunction(str(self.fit_function),
                                                                                           len(self.dataset_names))
Example #11
0
    def setUp(self):
        self.context = setup_context(True)
        self.workspace_finder = WorkspaceFinder(self.context)

        test_group = MuonGroup(group_name="fwd", detector_ids=[1, 2, 3, 4, 5])
        self.context.group_pair_context._groups = [test_group]
        self.context.group_pair_context._pairs = []
        self.context.group_pair_context._selected_groups = ["fwd"]
        self.context.group_pair_context._selected_pairs = []
Example #12
0
 def setUp(self):
     self.context = setup_context()
     self.context.data_context.current_runs = [[62260]]
     self.context.data_context.instrument = 'MUSR'
     self.widget = FittingTabWidget(self.context, parent=None)
     self.presenter = self.widget.fitting_tab_presenter
     self.view = self.widget.fitting_tab_view
     self.view.warning_popup = mock.MagicMock()
     self.presenter.model = mock.MagicMock()
     self.presenter.model.get_function_name.return_value = 'GausOsc'
 def setUp(self):
     self.model = FittingTabModel(setup_context())
     self.model.context.ads_observer.unsubscribe()
     self.model.fitting_options = {
         "startX": START_X,
         "endX": END_X,
         "evaluation_type": EVALUATION_TYPE,
         "minimiser": MINIMISER,
         "fit_type": "Single",
         "tf_asymmetry_mode": False
     }
    def setUp(self):
        self.context = setup_context()
        self.view = mock.MagicMock()
        self.view.fit_table = mock.MagicMock()
        self.model = mock.MagicMock()
        self.widget = SeqFittingTabWidget(context=self.context, model=self.model, parent=None, view=self.view)
        self.presenter = self.widget.seq_fitting_tab_presenter
        self.view.is_plotting_checked.return_value = False
        self.view.use_initial_values_for_fits.return_value = False
        self.presenter.create_thread = mock.MagicMock()

        self.view.fit_table.get_workspace_info_from_row = mock.MagicMock(return_value=["2224;2225", "bwd;fwd;top"])
Example #15
0
    def setUp(self):
        self.context = setup_context()
        self.view = mock.MagicMock()
        self.view.fit_table = mock.MagicMock()
        self.model = mock.MagicMock()
        self.presenter = SeqFittingTabPresenter(self.view, self.model,
                                                self.context)

        self.view.is_plotting_checked.return_value = False
        self.view.use_initial_values_for_fits.return_value = False
        self.presenter.create_thread = mock.MagicMock()

        self.view.fit_table.get_workspace_info_from_row = mock.MagicMock(
            return_value=["2224;2225", "bwd;fwd;top"])
    def setUp(self):
        self.view = PhaseTableView()
        self.context = setup_context()
        self.context.data_context.instrument = 'MUSR'

        self.presenter = PhaseTablePresenter(self.view, self.context)

        forward_group = MuonGroup(group_name="fwd", detector_ids=[1,3,5,7,9])
        backward_group = MuonGroup(group_name="bwd", detector_ids=[2,4,6,8,10])

        self.context.group_pair_context.add_group(forward_group)
        self.context.group_pair_context.add_group(backward_group)
        self.presenter.update_current_groups_list()

        self.view.warning_popup = mock.MagicMock()
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        self.view = PhaseTableView()
        self.context = setup_context()
        self.context.data_context.instrument = 'MUSR'

        self.presenter = PhaseTablePresenter(self.view, self.context)

        forward_group = MuonGroup(group_name="fwd", detector_ids=[1,3,5,7,9])
        backward_group = MuonGroup(group_name="bwd", detector_ids=[2,4,6,8,10])

        self.context.group_pair_context.add_group(forward_group)
        self.context.group_pair_context.add_group(backward_group)
        self.presenter.update_current_groups_list()

        self.view.warning_popup = mock.MagicMock()
    def setUp(self):
        self.context = setup_context(True)
        self.plotting_window_model = mock.MagicMock()
        self.view = mock.MagicMock()
        self.model = mock.MagicMock()
        self.workspace_list = [
            'MUSR62260; Group; bottom; Asymmetry; FD',
            'MUSR62261; Group; bottom; Asymmetry; FD',
            'FFT; Re MUSR62260; Group; fwd; Asymmetry; FD; Im MUSR62260; Group; fwd; Asymmetry; FD_Im'
            'FFT; Re MUSR62260; Group; fwd; Asymmetry; FD; Im MUSR62260; Group; fwd; Asymmetry; FD_Re'
            'FFT; Re MUSR62260; Group; fwd; Asymmetry; FD; Im MUSR62260; Group; fwd; Asymmetry; FD_mod'
            'MUSR62260_raw_data FD; MaxEnt'
        ]

        self.presenter = HomePlotWidgetPresenter(self.view, self.model,
                                                 self.context)
        self.presenter.get_plot_title = mock.MagicMock(
            return_value='MUSR62260-62261 bottom')
    def _setup_presenter(self):
        self.context = setup_context()
        self.presenter = CorrectionsPresenter(self.view, self.model,
                                              self.context)
        self.presenter.disable_editing_notifier = mock.Mock()
        self.presenter.enable_editing_notifier = mock.Mock()
        self.presenter.asymmetry_pair_and_diff_calculations_finished_notifier = mock.Mock(
        )

        self.presenter.dead_time_presenter.initialize_model_options = mock.Mock(
        )
        self.presenter.dead_time_presenter.handle_ads_clear_or_remove_workspace_event = mock.Mock(
        )
        self.presenter.dead_time_presenter.handle_instrument_changed = mock.Mock(
        )
        self.presenter.dead_time_presenter.handle_run_selector_changed = mock.Mock(
        )
        self.presenter.dead_time_presenter.handle_pre_process_and_counts_calculated = mock.Mock(
        )

        self.presenter.background_presenter.initialize_model_options = mock.Mock(
        )
        self.presenter.background_presenter.handle_instrument_changed = mock.Mock(
        )
        self.presenter.background_presenter.handle_runs_loaded = mock.Mock()
        self.presenter.background_presenter.handle_run_selector_changed = mock.Mock(
        )
        self.presenter.background_presenter.handle_groups_changed = mock.Mock()
        self.presenter.background_presenter.handle_pre_process_and_counts_calculated = mock.Mock(
        )
        self.presenter.background_presenter.handle_background_corrections_for_all_finished = mock.Mock(
        )

        self.presenter._handle_selected_table_is_invalid = mock.Mock()
        self.presenter._notify_perform_dead_time_corrections = mock.Mock()
        self.presenter._perform_asymmetry_pairs_and_diffs_calculation = mock.Mock(
        )

        # Mock the correction result property
        self.presenter.thread_model_wrapper = mock.Mock(spec=ThreadModel)
        self.mock_presenter_correction_results = mock.PropertyMock(
            return_value=(self.run_strings, self.groups))
        type(self.presenter.thread_model_wrapper
             ).result = self.mock_presenter_correction_results
    def setUp(self):
        self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0]
        self.load_result, self.run_number, self.filename, _ = load_workspace_from_filename(
            self.filepath)

        self.context = setup_context()
        self.context.gui_context.update({'RebinType': 'None'})
        self.model = CorrectionsModel(self.context)
        self.runs = [[84447], [84448], [84449]]
        self.coadd_runs = [[84447, 84448, 84449]]

        self.context.data_context.instrument = 'EMU'
        self.context.data_context._loaded_data.add_data(
            workspace=self.load_result,
            run=[self.run_number],
            filename=self.filename,
            instrument='EMU')
        self.context.data_context.current_runs = [[self.run_number]]
        self.context.data_context.update_current_data()
        self.context.group_pair_context.reset_group_and_pairs_to_default(
            self.load_result['OutputWorkspace'][0].workspace, 'EMU', '', 1)
Example #21
0
 def setUp(self):
     self.context = setup_context(True)
     # create widget
     self.widget = transform_widget.TransformWidget(self.context, FFTWidget,
                                                    MaxEntWidget)
     self.widget._maxent._presenter = mock.MagicMock(
     )  #create_autospec(maxent_presenter_new.MaxEntPresenter, spec_set=True)
     self.widget._fft._presenter = mock.MagicMock(
     )  #create_autospec(fft_presenter_new.FFTPresenter, spec_Set=True)
     # create the view
     self.view = mock.create_autospec(transform_view.TransformView,
                                      spec_set=False)
     self.view.getView = mock.Mock()
     self.view.getMethods = mock.Mock(return_value=["FFT", "MaxEnt"])
     self.view.hideAll = mock.Mock()
     self.view.showMethod = mock.Mock()
     self.view.selection = mock.create_autospec(
         transform_selection_view.TransformSelectionView, spec_set=True)
     self.view.selection.changeMethodSignal = mock.Mock()
     # set the mocked view to the widget
     self.widget.mockWidget(self.view)
Example #22
0
    def setUp(self):
        context = setup_context()
        context._do_rebin = mock.Mock(return_value=False)

        self.corrections_model = CorrectionsModel(context)
        self.model = BackgroundCorrectionsModel(self.corrections_model, context)
        self.model.clear_background_corrections_data()

        self.runs = ["84447", "84447", "84447", "84447"]
        self.groups = ["fwd", "bwd", "top", "bottom"]
        self.use_raws = [DEFAULT_USE_RAW] * len(self.groups)
        self.start_xs = [15.0] * 4
        self.end_xs = [30.0] * 4
        self.a0s = [0.0] * 4
        self.a0_errors = [0.0] * 4
        self.statuses = ["No background correction"] * 4

        self.fitted_a0 = 1.234
        self.fitted_a0_error = 0.005
        self.fitted_function = self._setup_fitted_function()
        self.fit_status = "success"
        self.chi_squared = 2.2
Example #23
0
    def setUp(self):
        context = setup_context()
        self.model = TFAsymmetryFittingModel(context, context.fitting_context)
        self.dataset_names = [
            "EMU20884; Group; fwd; Asymmetry",
            "EMU20884; Group; top; Asymmetry"
        ]
        self.tf_non_compliant_dataset_names = [
            "EMU20884; Group; fwd; Asymmetry",
            "EMU20884; Pair Asym; long; Asymmetry"
        ]
        self.fit_function = FunctionFactory.createFunction("FlatBackground")
        self.single_fit_functions = [
            self.fit_function.clone(),
            self.fit_function.clone()
        ]
        self.simultaneous_fit_function = FunctionFactory.createInitializedMultiDomainFunction(
            str(self.fit_function), len(self.dataset_names))

        self.tf_single_function = create_tf_asymmetry_function(
            self.fit_function.clone())
        self.tf_single_fit_functions = [
            self.tf_single_function.clone(),
            self.tf_single_function.clone()
        ]
        self.tf_simultaneous_fit_function = FunctionFactory.createInitializedMultiDomainFunction(
            str(self.tf_single_function), len(self.dataset_names))

        CreateSampleWorkspace(Function="One Peak",
                              XMin=0.0,
                              XMax=15.0,
                              BinWidth=0.1,
                              OutputWorkspace=self.dataset_names[0])
        CreateSampleWorkspace(Function="One Peak",
                              XMin=0.0,
                              XMax=15.0,
                              BinWidth=0.1,
                              OutputWorkspace=self.dataset_names[1])
Example #24
0
    def setUp(self):
        self.loaded_data = MuonLoadData()

        self.context = setup_context(False)

        self.data_context = self.context.data_context
        self.gui_context = self.context.gui_context
        self.group_context = self.context.group_pair_context

        self.model = GroupingTabModel(context=self.context)

        self.grouping_table_view = GroupingTableView()
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.model)

        self.pairing_table_view = PairingTableView()
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.model)

        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()

        self.add_three_groups()
        self.add_two_pairs()

        self.view = GroupingTabView(self.grouping_table_view,
                                    self.pairing_table_view)
        self.presenter = GroupingTabPresenter(self.view, self.model,
                                              self.grouping_table_widget,
                                              self.pairing_table_widget)

        self.presenter.create_update_thread = mock.MagicMock(
            return_value=mock.MagicMock())
        self.view.display_warning_box = mock.MagicMock()
        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()
 def setUp(self):
     context = setup_context()
     self.corrections_model = CorrectionsModel(context)
     self.model = DeadTimeCorrectionsModel(self.corrections_model, context.data_context, context.corrections_context)
     self.runs = [[84447], [84448], [84449]]
     self.coadd_runs = [[84447, 84448, 84449]]
Example #26
0
 def setUp(self):
     self.model = FittingTabModel(setup_context())
 def setUp(self):
     self.model = FittingTabModel(setup_context())
     self.model.context.ads_observer.unsubscribe()
 def setUp(self):
     self.model = BasePaneModel(context=setup_context(False))
Example #29
0
 def setUpClass(cls):
     cls.context = setup_context()
 def setUp(self):
     self.context = setup_context(False)
     self.context.data_context.instrument = "MUSR"
     self.model = RawPaneModel(self.context)
     self.name = self.model.name
Example #31
0
 def setUp(self):
     self.context = setup_context()
     self.view = mock.MagicMock()
     self.model = mock.MagicMock()
     self.presenter = SeqFittingTabPresenter(self.view, self.model,
                                             self.context)