def setUp(self): AnalysisDataService.clear() self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0] self.load_result, self.run_number, self.filename = load_workspace_from_filename( self.filepath) self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext() self.gui_context.update({'RebinType': 'None'}) self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.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', '')
def setup_context_for_tests(parent_object): parent_object.loaded_data = MuonLoadData() parent_object.loaded_data.get_main_field_direction = mock.MagicMock(return_value='transverse') parent_object.data_context = MuonDataContext(load_data=parent_object.loaded_data) parent_object.gui_context = MuonGuiContext() parent_object.group_context = MuonGroupPairContext(parent_object.data_context.check_group_contains_valid_detectors) parent_object.phase_table_context = PhaseTableContext() parent_object.fitting_context = FittingContext() parent_object.context = MuonContext(muon_data_context=parent_object.data_context, muon_group_context=parent_object.group_context, muon_gui_context=parent_object.gui_context, muon_phase_context=parent_object.phase_table_context, fitting_context=parent_object.fitting_context)
def setup_context(): loaded_data = MuonLoadData() loaded_data.get_main_field_direction = mock.MagicMock( return_value='transverse') data_context = MuonDataContext(loaded_data) gui_context = MuonGuiContext() group_context = MuonGroupPairContext( data_context.check_group_contains_valid_detectors) phase_table_context = PhaseTableContext() return MuonContext(muon_data_context=data_context, muon_group_context=group_context, muon_gui_context=gui_context, muon_phase_context=phase_table_context)
def setup_context(freq = False): loaded_data = MuonLoadData() loaded_data.get_main_field_direction = mock.MagicMock(return_value='transverse') data_context = MuonDataContext(load_data=loaded_data) gui_context = MuonGuiContext() group_context = MuonGroupPairContext(data_context.check_group_contains_valid_detectors) phase_table_context = PhaseTableContext() fitting_context = FittingContext() freq_context = None if freq: freq_context = FrequencyContext() return MuonContext(muon_data_context=data_context, muon_group_context=group_context, muon_gui_context=gui_context, muon_phase_context=phase_table_context, fitting_context=fitting_context, frequency_context = freq_context)
def setUp(self): AnalysisDataService.clear() self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0] self.load_result, self.run_number, self.filename = load_workspace_from_filename(self.filepath) self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext() self.gui_context.update({'RebinType': 'None'}) self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.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', '')
def setUp(self): self._qapp = mock_widget.mockQapp() # Store an empty widget to parent all the views, and ensure they are deleted correctly self.obj = QtGui.QWidget() self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_context = MuonGroupPairContext( self.data_context.check_group_contains_valid_detectors) self.context = MuonContext(muon_data_context=self.data_context, muon_group_context=self.group_context, muon_gui_context=self.gui_context) self.model = GroupingTabModel(context=self.context) self.grouping_table_view = GroupingTableView(parent=self.obj) self.grouping_table_widget = GroupingTablePresenter( self.grouping_table_view, self.model) self.pairing_table_view = PairingTableView(parent=self.obj) self.pairing_table_widget = PairingTablePresenter( self.pairing_table_view, self.model) self.add_three_groups() self.add_two_pairs() self.view = GroupingTabView(self.grouping_table_view, self.pairing_table_view, parent=self.obj) 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 __init__(self, context=MuonContext()): self._data = context.data_context self._context = context self._context.gui_context['RebinType'] = 'None'
def __init__(self, parent=None): super(MuonAnalysisGui, self).__init__(parent) self.setFocusPolicy(QtCore.Qt.StrongFocus) try: check_facility() except AttributeError as error: self.warning_popup(error.args[0]) # initialise the data storing classes of the interface self.loaded_data = MuonLoadData() self.data_context = MuonDataContext('Muon Data', self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext( self.data_context.check_group_contains_valid_detectors) self.phase_context = PhaseTableContext() self.fitting_context = FittingContext() self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.group_pair_context, muon_phase_context=self.phase_context, fitting_context=self.fitting_context, workspace_suffix=' MA') # create the dockable widget self.dockable_plot_widget = PlottingWidget(self.context) self.dockable_plot_widget_window = PlottingDockWidget( parent=self, plotting_widget=self.dockable_plot_widget.view) self.dockable_plot_widget_window.setMinimumWidth(575) # Add dock widget to main Muon analysis window self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.dockable_plot_widget_window) # Need this line to stop the bug where the dock window snaps back to its original size after resizing. # This is a qt bug reported at (https://bugreports.qt.io/browse/QTBUG-65592) if QT_VERSION >= LooseVersion("5.6"): self.resizeDocks({self.dockable_plot_widget_window}, {40}, QtCore.Qt.Horizontal) # set up other widgets self.load_widget = LoadWidget(self.loaded_data, self.context, self) self.home_tab = HomeTabWidget(self.context, self) self.grouping_tab_widget = GroupingTabWidget(self.context) self.phase_tab = PhaseTabWidget(self.context, self) self.fitting_tab = FittingTabWidget(self.context, self) self.seq_fitting_tab = SeqFittingTabWidget( self.context, self.fitting_tab.fitting_tab_model, self) self.results_tab = ResultsTabWidget(self.context.fitting_context, self.context, self) self.setup_tabs() self.help_widget = HelpWidget("Muon Analysis 2") central_widget = QtWidgets.QWidget() vertical_layout = QtWidgets.QVBoxLayout() vertical_layout.addWidget(self.load_widget.load_widget_view) vertical_layout.addWidget(self.tabs) vertical_layout.addWidget(self.help_widget.view) central_widget.setLayout(vertical_layout) self.setCentralWidget(central_widget) self.setWindowTitle(self.context.window_title) self.setup_load_observers() self.setup_gui_variable_observers() self.setup_grouping_changed_observers() self.setup_instrument_changed_notifier() self.setup_group_calculation_enable_notifier() self.setup_group_calculation_disabler_notifier() self.setup_on_load_enabler() self.setup_on_load_disabler() self.setup_phase_quad_changed_notifier() self.setup_phase_table_changed_notifier() self.setup_fitting_notifier() self.setup_on_recalulation_finished_notifier() self.context.data_context.message_notifier.add_subscriber( self.grouping_tab_widget.group_tab_presenter.message_observer)
def __init__(self, context=MuonContext()): self._data = context.data_context self._context = context
def __init__(self, parent=None): super(FrequencyAnalysisGui, self).__init__(parent) self.setFocusPolicy(QtCore.Qt.StrongFocus) try: check_facility() except AttributeError as error: self.warning_popup(error.args[0]) # initialise the data storing classes of the interface self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext( self.data_context.check_group_contains_valid_detectors) self.phase_context = PhaseTableContext() self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.group_pair_context, muon_phase_context=self.phase_context) # construct all the widgets. self.load_widget = LoadWidget(self.loaded_data, self.context, self) self.grouping_tab_widget = GroupingTabWidget(self.context) self.home_tab = HomeTabWidget(self.context, self) self.phase_tab = PhaseTabWidget(self.context, self) self.transform = TransformWidget(self.context, FFTWidget, MaxEntWidget, parent=self) self.setup_tabs() self.help_widget = HelpWidget("Frequency Domain Analysis") central_widget = QtWidgets.QWidget() vertical_layout = QtWidgets.QVBoxLayout() vertical_layout.addWidget(self.load_widget.load_widget_view) vertical_layout.addWidget(self.tabs) vertical_layout.addWidget(self.help_widget.view) central_widget.setLayout(vertical_layout) self.setCentralWidget(central_widget) self.setWindowTitle("Frequency Domain Analysis") self.setup_load_observers() self.setup_gui_variable_observers() self.setup_alpha_recalculated_observers() self.setup_grouping_changed_observers() self.setup_instrument_changed_notifier() self.setup_group_calculation_enable_notifer() self.setup_group_calculation_disabler_notifer() self.setup_on_load_enabler() self.setup_on_load_disabler() self.setup_phase_quad_changed_notifer() self.setup_phase_table_changed_notifier() self.context.data_context.message_notifier.add_subscriber( self.grouping_tab_widget.group_tab_presenter.message_observer)
class MuonContextTest(unittest.TestCase): @classmethod def setUpClass(cls): pass def setUp(self): AnalysisDataService.clear() self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0] self.load_result, self.run_number, self.filename = load_workspace_from_filename( self.filepath) self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext() self.gui_context.update({'RebinType': 'None'}) self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.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', '') def populate_ADS(self): self.context.calculate_all_groups() self.context.show_all_groups() self.context.calculate_all_pairs() self.context.show_all_pairs() workspace = CreateWorkspace([0], [0], StoreInADS=False) self.context.phase_context.add_phase_quad( MuonWorkspaceWrapper(workspace, 'EMU19489; PhaseQuad; PhaseTable EMU19489')) def test_reset_groups_and_pairs_to_default(self): self.assertEquals(self.group_pair_context.group_names, ['fwd', 'bwd']) self.assertEquals(self.group_pair_context.pair_names, ['long']) def test_calculate_group_calculates_group_for_given_run(self): counts_workspace, asymmetry_workspace = self.context.calculate_group( 'fwd', run=[19489]) self.assertEquals(type(counts_workspace), Workspace2D) self.assertEquals(type(counts_workspace), Workspace2D) def test_calculate_pair_calculates_pair_for_given_run(self): pair_asymmetry = self.context.calculate_pair('long', run=[19489]) self.assertEquals(type(pair_asymmetry), Workspace2D) def test_show_all_groups_calculates_and_shows_all_groups(self): self.context.show_all_groups() self.assertEquals(AnalysisDataService.getObjectNames(), [ 'EMU19489', 'EMU19489 Groups', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Group; bwd; Counts; #1', 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; fwd; Counts; #1', 'Muon Data' ]) def test_that_show_all_calculates_and_shows_all_groups_with_rebin(self): self.gui_context['RebinType'] = 'Fixed' self.gui_context['RebinFixed'] = 2 self.context.show_all_groups() self.assertEquals(AnalysisDataService.getObjectNames(), [ 'EMU19489', 'EMU19489 Groups', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; Rebin; #1', 'EMU19489; Group; bwd; Counts; #1', 'EMU19489; Group; bwd; Counts; Rebin; #1', 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; fwd; Asymmetry; Rebin; #1', 'EMU19489; Group; fwd; Counts; #1', 'EMU19489; Group; fwd; Counts; Rebin; #1', 'Muon Data' ]) def test_show_all_pairs_calculates_and_shows_all_pairs(self): self.context.show_all_pairs() self.assertEquals(AnalysisDataService.getObjectNames(), [ 'EMU19489', 'EMU19489 Pairs', 'EMU19489; Pair Asym; long; #1', 'Muon Data' ]) def test_that_show_all_calculates_and_shows_all_pairs_with_rebin(self): self.gui_context['RebinType'] = 'Fixed' self.gui_context['RebinFixed'] = 2 self.context.show_all_pairs() self.assertEquals(AnalysisDataService.getObjectNames(), [ 'EMU19489', 'EMU19489 Pairs', 'EMU19489; Pair Asym; long; #1', 'EMU19489; Pair Asym; long; Rebin; #1', 'Muon Data' ]) def test_update_current_data_sets_current_run_in_data_context(self): self.context.update_current_data() self.assertEquals(self.data_context.current_data, self.load_result) def test_update_current_data_sets_groups_and_pairs(self): self.context.update_current_data() self.assertEquals(self.group_pair_context.pair_names, ['long']) self.assertEquals(self.group_pair_context.group_names, ['fwd', 'bwd']) def test_show_raw_data_puts_raw_data_into_the_ADS(self): self.context.show_raw_data() self.assertEquals(AnalysisDataService.getObjectNames(), [ 'EMU19489', 'EMU19489 Raw Data', 'EMU19489_raw_data', 'Muon Data' ]) def test_that_first_good_data_returns_correctly_when_from_file_chosen_option( self): self.gui_context.update({'FirstGoodDataFromFile': True}) first_good_data = self.context.first_good_data([19489]) self.assertEquals(first_good_data, 0.11) def test_first_good_data_returns_correctly_when_manually_specified_used( self): self.gui_context.update({ 'FirstGoodDataFromFile': False, 'FirstGoodData': 5 }) first_good_data = self.context.first_good_data([19489]) self.assertEquals(first_good_data, 5) def test_that_last_good_data_returns_correctly_when_from_file_chosen_option( self): self.gui_context.update({'LastGoodDataFromFile': True}) last_good_data = self.context.last_good_data([19489]) self.assertEquals(last_good_data, 31.76) def test_last_good_data_returns_correctly_when_manually_specified_used( self): self.gui_context.update({ 'LastGoodDataFromFile': False, 'LastGoodData': 5 }) last_good_data = self.context.last_good_data([19489]) self.assertEquals(last_good_data, 5) def test_that_dead_time_table_from_ADS_returns_table_name(self): self.gui_context.update({ 'DeadTimeSource': 'FromADS', 'DeadTimeTable': 'deadtime_table_name' }) deadtime_table = self.context.dead_time_table([19489]) self.assertEquals(deadtime_table, 'deadtime_table_name') def test_get_workspace_names_returns_all_stored_workspaces_if_all_selected( self): self.populate_ADS() workspace_list = self.context.get_names_of_workspaces_to_fit( '19489', 'fwd, bwd, long', True) self.assertEqual(workspace_list, [ 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Pair Asym; long; #1', 'EMU19489; PhaseQuad; PhaseTable EMU19489' ]) def test_get_workspace_names_returns_nothing_if_no_parameters_passed(self): self.populate_ADS() workspace_list = self.context.get_names_of_workspaces_to_fit() self.assertEqual(workspace_list, []) def test_get_workspaces_names_copes_with_bad_groups(self): self.populate_ADS() workspace_list = self.context.get_names_of_workspaces_to_fit( '19489', 'fwd, bwd, long, random, wrong', True) self.assertEqual(workspace_list, [ 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Pair Asym; long; #1', 'EMU19489; PhaseQuad; PhaseTable EMU19489' ]) def test_get_workspaces_names_copes_with_non_existent_runs(self): self.populate_ADS() workspace_list = self.context.get_names_of_workspaces_to_fit( '19489, 22222', 'fwd, bwd, long', True) self.assertEqual(workspace_list, [ 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Pair Asym; long; #1', 'EMU19489; PhaseQuad; PhaseTable EMU19489' ]) def test_that_run_ranged_correctly_parsed(self): self.populate_ADS() workspace_list = self.context.get_names_of_workspaces_to_fit( '19489-95', 'fwd, bwd, long', True) self.assertEqual(workspace_list, [ 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Pair Asym; long; #1', 'EMU19489; PhaseQuad; PhaseTable EMU19489' ])
def __init__(self, parent=None): super(FrequencyAnalysisGui, self).__init__(parent) self.setFocusPolicy(QtCore.Qt.StrongFocus) try: check_facility() except AttributeError as error: self.warning_popup(error.args[0]) # initialise the data storing classes of the interface self.loaded_data = MuonLoadData() self.data_context = MuonDataContext('Frequency Domain Data', self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext( self.data_context.check_group_contains_valid_detectors) self.phase_context = PhaseTableContext() self.fitting_context = FittingContext() self.frequency_context = FrequencyContext() self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.group_pair_context, muon_phase_context=self.phase_context, fitting_context=self.fitting_context, workspace_suffix=' FD', frequency_context=self.frequency_context) # create the dockable widget self.dockable_plot_widget = PlottingWidget(self.context) self.dockable_plot_widget_window = PlottingDockWidget( parent=self, plotting_widget=self.dockable_plot_widget.view) self.dockable_plot_widget_window.setMinimumWidth(575) # # add dock widget to main Muon analysis window self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.dockable_plot_widget_window) # construct all the widgets. self.load_widget = LoadWidget(self.loaded_data, self.context, self) self.grouping_tab_widget = GroupingTabWidget(self.context) self.home_tab = HomeTabWidget(self.context, self) self.phase_tab = PhaseTabWidget(self.context, self) self.transform = TransformWidget(self.context, FFTWidget, MaxEntWidget, parent=self) self.fitting_tab = FittingTabWidget(self.context, self) self.results_tab = ResultsTabWidget(self.context.fitting_context, self.context, self) self.setup_tabs() self.help_widget = HelpWidget(self.context.window_title) central_widget = QtWidgets.QWidget() vertical_layout = QtWidgets.QVBoxLayout() vertical_layout.addWidget(self.load_widget.load_widget_view) vertical_layout.addWidget(self.tabs) vertical_layout.addWidget(self.help_widget.view) central_widget.setLayout(vertical_layout) self.setCentralWidget(central_widget) self.setWindowTitle(self.context.window_title) self.setup_load_observers() self.setup_gui_variable_observers() self.setup_grouping_changed_observers() self.setup_instrument_changed_notifier() self.setup_group_calculation_enable_notifier() self.setup_group_calculation_disabler_notifier() self.setup_on_load_enabler() self.setup_on_load_disabler() self.setup_phase_quad_changed_notifier() self.setup_phase_table_changed_notifier() self.setup_fitting_notifier() self.setup_on_recalculation_finished_notifier() self.transform.set_up_calculation_observers( self.fitting_tab.fitting_tab_presenter.enable_tab_observer, self.fitting_tab.fitting_tab_presenter.disable_tab_observer) self.transform.new_data_observer( self.fitting_tab.fitting_tab_presenter.input_workspace_observer) self.transform.new_data_observer( self.dockable_plot_widget.presenter.input_workspace_observer) self.context.data_context.message_notifier.add_subscriber( self.grouping_tab_widget.group_tab_presenter.message_observer)
class MuonContextTest(unittest.TestCase): @classmethod def setUpClass(cls): pass def setUp(self): AnalysisDataService.clear() self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0] self.load_result, self.run_number, self.filename = load_workspace_from_filename(self.filepath) self.loaded_data = MuonLoadData() self.data_context = MuonDataContext(self.loaded_data) self.gui_context = MuonGuiContext() self.group_pair_context = MuonGroupPairContext() self.gui_context.update({'RebinType': 'None'}) self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.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', '') def test_reset_groups_and_pairs_to_default(self): self.assertEquals(self.group_pair_context.group_names, ['fwd', 'bwd']) self.assertEquals(self.group_pair_context.pair_names, ['long']) def test_calculate_group_calculates_group_for_given_run(self): counts_workspace, asymmetry_workspace = self.context.calculate_group('fwd', run=[19489]) self.assertEquals(type(counts_workspace), Workspace2D) self.assertEquals(type(counts_workspace), Workspace2D) def test_calculate_pair_calculates_pair_for_given_run(self): pair_asymmetry = self.context.calculate_pair('long', run=[19489]) self.assertEquals(type(pair_asymmetry), Workspace2D) def test_show_all_groups_calculates_and_shows_all_groups(self): self.context.show_all_groups() self.assertEquals(AnalysisDataService.getObjectNames(), ['EMU19489', 'EMU19489 Groups', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Group; bwd; Counts; #1', 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; fwd; Counts; #1', 'Muon Data']) def test_that_show_all_calculates_and_shows_all_groups_with_rebin(self): self.gui_context['RebinType'] = 'Fixed' self.gui_context['RebinFixed'] = 2 self.context.show_all_groups() self.assertEquals(AnalysisDataService.getObjectNames(), ['EMU19489', 'EMU19489 Groups', 'EMU19489; Group; bwd; Asymmetry; #1', 'EMU19489; Group; bwd; Asymmetry; Rebin; #1', 'EMU19489; Group; bwd; Counts; #1', 'EMU19489; Group; bwd; Counts; Rebin; #1', 'EMU19489; Group; fwd; Asymmetry; #1', 'EMU19489; Group; fwd; Asymmetry; Rebin; #1', 'EMU19489; Group; fwd; Counts; #1', 'EMU19489; Group; fwd; Counts; Rebin; #1', 'Muon Data']) def test_show_all_pairs_calculates_and_shows_all_pairs(self): self.context.show_all_pairs() self.assertEquals(AnalysisDataService.getObjectNames(), ['EMU19489', 'EMU19489 Pairs', 'EMU19489; Pair Asym; long; #1', 'Muon Data']) def test_that_show_all_calculates_and_shows_all_pairs_with_rebin(self): self.gui_context['RebinType'] = 'Fixed' self.gui_context['RebinFixed'] = 2 self.context.show_all_pairs() self.assertEquals(AnalysisDataService.getObjectNames(), ['EMU19489', 'EMU19489 Pairs', 'EMU19489; Pair Asym; long; #1', 'EMU19489; Pair Asym; long; Rebin; #1', 'Muon Data']) def test_update_current_data_sets_current_run_in_data_context(self): self.context.update_current_data() self.assertEquals(self.data_context.current_data, self.load_result) def test_update_current_data_sets_groups_and_pairs(self): self.context.update_current_data() self.assertEquals(self.group_pair_context.pair_names, ['long']) self.assertEquals(self.group_pair_context.group_names, ['fwd', 'bwd']) def test_show_raw_data_puts_raw_data_into_the_ADS(self): self.context.show_raw_data() self.assertEquals(AnalysisDataService.getObjectNames(), ['EMU19489', 'EMU19489 Raw Data', 'EMU19489_raw_data', 'Muon Data']) def test_that_first_good_data_returns_correctly_when_from_file_chosen_option(self): self.gui_context.update({'FirstGoodDataFromFile': True}) first_good_data = self.context.first_good_data([19489]) self.assertEquals(first_good_data, 0.11) def test_first_good_data_returns_correctly_when_manually_specified_used(self): self.gui_context.update({'FirstGoodDataFromFile': False, 'FirstGoodData': 5}) first_good_data = self.context.first_good_data([19489]) self.assertEquals(first_good_data, 5) def test_that_last_good_data_returns_correctly_when_from_file_chosen_option(self): self.gui_context.update({'LastGoodDataFromFile': True}) last_good_data = self.context.last_good_data([19489]) self.assertEquals(last_good_data, 31.76) def test_last_good_data_returns_correctly_when_manually_specified_used(self): self.gui_context.update({'LastGoodDataFromFile': False, 'LastGoodData': 5}) last_good_data = self.context.last_good_data([19489]) self.assertEquals(last_good_data, 5) def test_that_dead_time_table_from_ADS_returns_table_name(self): self.gui_context.update({'DeadTimeSource': 'FromADS', 'DeadTimeTable': 'deadtime_table_name'}) deadtime_table = self.context.dead_time_table([19489]) self.assertEquals(deadtime_table, 'deadtime_table_name')
def __init__(self, context=MuonContext()): self._context = context self._data = context.data_context self._groups_and_pairs = context.group_pair_context self._gui_variables = context.gui_context