def test_create_tiled_keys_returns_correctly_for_tiled_by_group(self):
        self.context.group_context.add_group(
            EAGroup(group_name="9998; Detector 1",
                    detector="Detector 1",
                    run_number="9999"))
        self.context.group_context.add_group(
            EAGroup(group_name="9999; Detector 2",
                    detector="Detector 2",
                    run_number="9998"))
        self.context.group_context._selected_groups = [
            "9999; Detector 1", "9998; Detector 1", "9999; Detector 2"
        ]
        runs = [[9999], [9998]]
        self.context.data_context.current_runs = runs
        keys = self.model.create_tiled_keys("Detector")

        self.assertEqual(keys, ["Detector 1", "Detector 2"])
 def setUp(self):
     setup_context_for_ea_tests(self)
     self.model = EAPlotDataPaneModel(context=self.context)
     self.name = "9999; Detector 1"
     test_group = EAGroup(group_name=self.name,
                          detector="Detector 1",
                          run_number="9999")
     self.context.group_context._groups = [test_group]
     self.context.group_context._selected_groups = [self.name]
    def test_create_tiled_keys_returns_correctly_for_tiled_by_run(self):
        self.context.group_context.add_group(
            EAGroup(group_name="9997; Detector 2",
                    detector="Detector 2",
                    run_number="9997"))
        self.context.group_context.add_group(
            EAGroup(group_name="9998; Detector 3",
                    detector="Detector 3",
                    run_number="9998"))
        self.context.group_context.add_group(
            EAGroup(group_name="9999; Detector 4",
                    detector="Detector 4",
                    run_number="9999"))
        self.context.group_context._selected_groups = [
            "9997; Detector 2", "9999; Detector 4"
        ]
        runs = [[9997, 9998, 9999]]
        self.context.data_context.current_runs = runs
        keys = self.model.create_tiled_keys("Run")

        self.assertEqual(keys, ['9997', '9999'])
Exemplo n.º 4
0
def get_default_grouping(loadedData, error_notifier=None):
    """this creates the first set of groups listed in the grouping table of the Elemental Analysis GUI
        For single workspace names the detector is found by taking everything after ; in the name
        For example : 2695; Detector 1 --> Detector 1
        For co-added workspaces the detector is found by taking everything before
        For example : Detector 1_2695-2686 --> Detector 1
    """
    groups = []
    run_list = loadedData.get_parameter("run")
    for run_item in run_list:
        for workspace in loadedData.get_data(run=run_item)["workspace"]:
            group_name = str(workspace)
            if not is_group_valid(group_name):
                continue
            detector_name = (group_name.split(';',
                                              1)[-1].lstrip()).split('_', 1)[0]
            run_number = str(run_item).replace('[', '').replace(']', '')
            group = EAGroup(group_name=group_name,
                            detector=detector_name,
                            run_number=run_number)
            if error_notifier is not None:
                group.set_error_notifier(error_notifier)
            groups += [group]
    return groups
    def setUp(self):
        workspaces = [
            "9999; Detector 1", "9999; Detector 2", "9999; Detector 3",
            "9999; Detector 4"
        ]
        self.group_context = EAGroupContext()
        for group_name in workspaces:
            group = EAGroup(group_name,
                            group_name.split(";")[1].strip(),
                            group_name.split(";")[0].strip())
            group.update_peak_table(group_name + PEAKS_WS_SUFFIX)
            group.update_matches_table(group_name + MATCH_GROUP_WS_SUFFIX)
            self.group_context.add_group(group)

        self.context = ElementalAnalysisContext(None, self.group_context)
        self.presenter = EAAutoTabPresenter(self.context, mock.Mock(),
                                            mock.Mock(), mock.Mock())
 def test_add_group_from_table_with_valid_argument(self):
     mock_group = EAGroup("9999; Detector 1", "detector 1", "9999")
     self.model.add_group_from_table(mock_group)
     self.model._groups.add_group.assert_called_once_with(mock_group)
 def test_add_group_with_valid_argument(self):
     mock_group = EAGroup("9999; Detector 1", "detector 1", "9999")
     self.model.add_group(mock_group)
     self.model._groups.add_new_group.assert_called_once_with(mock_group, self.model._data._loaded_data)