示例#1
0
    def show_group(self, run, group, rebin):
        run_as_string = run_list_to_string(run)
        group_name = group.name
        periods = run_list_to_string(group.periods)

        directory = get_base_data_directory(self, run_as_string)

        name = get_group_data_workspace_name(self,
                                             group_name,
                                             run_as_string,
                                             periods,
                                             rebin=rebin)
        asym_name = get_group_asymmetry_name(self,
                                             group_name,
                                             run_as_string,
                                             periods,
                                             rebin=rebin)
        asym_name_unnorm = get_group_asymmetry_unnorm_name(self,
                                                           group_name,
                                                           run_as_string,
                                                           periods,
                                                           rebin=rebin)

        if not rebin:
            self.group_pair_context[group_name].show_raw(
                run, directory + name, directory + asym_name, asym_name_unnorm)
        else:
            self.group_pair_context[group_name].show_rebin(
                run, directory + name, directory + asym_name, asym_name_unnorm)
    def get_plot_title(self):
        """
        Generates a title for the plot based on current instrument group and run numbers
        :return: Plot titles
        """
        flattened_run_list = [
            item for sublist in self.context.data_context.current_runs
            for item in sublist
        ]
        instrument = self.context.data_context.instrument
        plot_titles = []

        if self._view.is_tiled_plot():
            if self._view.get_tiled_by_type() == 'run':
                for run in flattened_run_list:
                    plot_titles.append(instrument + str(run))
            else:
                for grouppair in self.context.group_pair_context.selected_groups + \
                                 self.context.group_pair_context.selected_pairs:
                    title = self.context.data_context.instrument + ' ' + run_list_to_string(flattened_run_list) + \
                            ' ' + str(grouppair)
                    plot_titles.append(title)
            return plot_titles
        else:
            return [
                self.context.data_context.instrument + ' ' +
                run_list_to_string(flattened_run_list)
            ]
示例#3
0
 def getWorkspaceNames(self, use_raw):
     pair_names = list(self.context.group_pair_context.pair_names)
     group_names = list(self.context.group_pair_context.group_names)
     run_numbers = self.context.data_context.current_runs
     final_options = []
     for run in run_numbers:
         final_options += [
             wsName.get_raw_data_workspace_name(self.context,
                                                run_list_to_string(run),
                                                period=str(period + 1)) +
             " (PhaseQuad)"
             for period in range(self.context.data_context.num_periods(run))
         ]
         for name in pair_names:
             final_options.append(
                 wsName.get_pair_data_workspace_name(
                     self.context, str(name), run_list_to_string(run),
                     not use_raw))
         for group_name in group_names:
             final_options.append(
                 wsName.get_group_asymmetry_name(self.context,
                                                 str(group_name),
                                                 run_list_to_string(run),
                                                 not use_raw))
     return final_options
 def add_group_to_view(self, group, state, color, tooltip):
     self._view.disable_updates()
     assert isinstance(group, MuonGroup)
     entry = [
         str(group.name),
         run_utils.run_list_to_string(group.periods), state,
         run_utils.run_list_to_string(group.detectors, False),
         str(group.n_detectors)
     ]
     self._view.add_entry_to_table(entry, color, tooltip)
     self._view.enable_updates()
示例#5
0
def _create_XML_subElement_for_groups(root_node, groups):
    group_nodes = []
    for group in groups:
        child = ET.SubElement(root_node, 'group', name=group.name)
        id_string = run_string_utils.run_list_to_string(group.detectors)
        ids = ET.SubElement(child, 'ids', val=id_string)
        child.extend(ids)
        period_string = run_string_utils.run_list_to_string(group.periods)
        periods = ET.SubElement(child, 'periods', val=period_string)
        child.extend(periods)
        group_nodes += [child]
    return group_nodes
示例#6
0
    def show_all_groups(self):
        self.calculate_all_groups()
        for run in self._data_context.current_runs:
            with WorkspaceGroupDefinition():
                for group in self._group_pair_context.groups:
                    run_as_string = run_list_to_string(run)
                    group_name = group.name
                    periods = run_list_to_string(group.periods)

                    directory = get_base_data_directory(self, run_as_string)

                    name = get_group_data_workspace_name(self,
                                                         group_name,
                                                         run_as_string,
                                                         periods,
                                                         rebin=False)
                    asym_name = get_group_asymmetry_name(self,
                                                         group_name,
                                                         run_as_string,
                                                         periods,
                                                         rebin=False)
                    asym_name_unnorm = get_group_asymmetry_unnorm_name(
                        self, group_name, run_as_string, periods, rebin=False)

                    self.group_pair_context[group_name].show_raw(
                        run, directory + name, directory + asym_name,
                        asym_name_unnorm)

                    if self._do_rebin():
                        name = get_group_data_workspace_name(self,
                                                             group_name,
                                                             run_as_string,
                                                             periods,
                                                             rebin=True)
                        asym_name = get_group_asymmetry_name(self,
                                                             group_name,
                                                             run_as_string,
                                                             periods,
                                                             rebin=True)
                        asym_name_unnorm = get_group_asymmetry_unnorm_name(
                            self,
                            group_name,
                            run_as_string,
                            periods,
                            rebin=True)

                        self.group_pair_context[group_name].show_rebin(
                            run, directory + name, directory + asym_name,
                            asym_name_unnorm)
示例#7
0
    def show_all_pairs(self):
        self.calculate_all_pairs()
        for run in self._data_context.current_runs:
            for pair_name in self._group_pair_context.pair_names:
                run_as_string = run_list_to_string(run)
                name = get_pair_data_workspace_name(
                    self,
                    pair_name,
                    run_as_string,
                    rebin=False)
                directory = get_base_data_directory(
                    self,
                    run_as_string)

                self.group_pair_context[
                    pair_name].show_raw(run, directory + name)

                if self._do_rebin():
                    name = get_pair_data_workspace_name(
                        self,
                        pair_name,
                        run_as_string,
                        rebin=True)
                    self.group_pair_context[
                        pair_name].show_rebin(run, directory + name)
示例#8
0
    def create_multiple_field_directions_error_message(self, run_list):
        transverse = []
        longitudinal = []
        for run in run_list:
            field_direction = self._loaded_data.get_main_field_direction(run=run, instrument=self.instrument)
            if field_direction.lower() == 'transverse':
                transverse += run
            elif field_direction.lower() == 'longitudinal':
                longitudinal += run
            else:
                return 'Unrecognised field direction {} for run {}'.format(field_direction, run)

        message = 'MainFieldDirection changes within current run set:\n'
        message += 'transverse field runs {}\n'.format(run_list_to_string(transverse))
        message += 'longitudinal field runs {}\n'.format(run_list_to_string(longitudinal))
        return message
示例#9
0
    def get_names_of_workspaces_to_fit(self, runs='', group_and_pair='', phasequad=False, rebin=False):
        if group_and_pair == 'All':
            group = self.group_pair_context.group_names
            pair = self.group_pair_context.pair_names
        else:
            group_pair_list = group_and_pair.replace(' ', '').split(',')
            group = [group for group in group_pair_list if group in self.group_pair_context.group_names]
            pair = [pair for pair in group_pair_list if pair in self.group_pair_context.pair_names]

        if runs == 'All':
            run_list = self.data_context.current_runs
        else:
            run_list = [run_string_to_list(item) for item in runs.replace(' ', '').split(',')]
            flat_list = []
            for sublist in run_list:
                flat_list += [[run] for run in sublist if len(sublist) > 1]
            run_list += flat_list
            run_list = [run for run in run_list if run in self.data_context.current_runs]

        group_names = self.group_pair_context.get_group_workspace_names(run_list, group, rebin)
        pair_names = self.group_pair_context.get_pair_workspace_names(run_list, pair, rebin)

        phasequad_names = []
        if phasequad:
            for run in run_list:
                run_string = run_list_to_string(run)
                phasequad_names += self.phase_context.get_phase_quad(self.data_context.instrument, run_string)

        return group_names + pair_names + phasequad_names
示例#10
0
 def calculate_pair(self, pair_name, run, rebin=False):
     run_as_string = run_list_to_string(run)
     name = get_pair_data_workspace_name(self,
                                         pair_name,
                                         run_as_string,
                                         rebin=rebin)
     return calculate_pair_data(self, pair_name, run, rebin, name)
示例#11
0
 def getGroupedWorkspaceNames(self):
     run_numbers = self.data_context.current_runs
     runs = [
         wsName.get_raw_data_workspace_name(
             self,
             run_list_to_string(run_number),
             period=str(period + 1))
         for run_number in run_numbers for period in range(self.data_context.num_periods(run_number))]
     return runs
示例#12
0
def _create_XML_subElement_for_groups(root_node, groups):
    group_nodes = []
    for group in groups:
        child = ET.SubElement(root_node, 'group', name=group.name)
        id_string = run_string_utils.run_list_to_string(group.detectors)
        ids = ET.SubElement(child, 'ids', val=id_string)
        child.extend(ids)
        group_nodes += [child]
    return group_nodes
 def create_tiled_keys(self, tiled_by):
     if tiled_by == "Group/Pair":
         keys = self.context.group_pair_context.selected_groups_and_pairs
     else:
         keys = [
             run_list_to_string(item)
             for item in self.context.data_context.current_runs
         ]
     return keys
 def get_plot_title(self):
     """
     Generates a title for the plot based on current instrument group and run numbers
     :return:
     """
     flattened_run_list = [
         item for sublist in self.context.data_context.current_runs for item in sublist]
     return self.context.data_context.instrument + ' ' + run_list_to_string(flattened_run_list) + ' ' + \
         self.context.group_pair_context.selected
示例#15
0
    def get_workspace_names_for_FFT_analysis(self, use_raw=True):
        pair_names = list(self.group_pair_context.pair_names)
        group_names = list(self.group_pair_context.group_names)
        run_numbers = self.data_context.current_runs
        workspace_options = []

        for run in run_numbers:
            workspace_options += self.phase_context.get_phase_quad(self.data_context.instrument, run_list_to_string(run))

            for name in pair_names:
                workspace_options.append(
                    wsName.get_pair_data_workspace_name(self,
                                                        str(name),
                                                        run_list_to_string(run), not use_raw))
            for group_name in group_names:
                workspace_options.append(
                    wsName.get_group_asymmetry_name(self, str(group_name), run_list_to_string(run),
                                                    not use_raw))
        return workspace_options
示例#16
0
 def getWorkspaceNames(self, use_raw):
     pair_names = list(self.context.group_pair_context.pair_names)
     group_names = list(self.context.group_pair_context.group_names)
     run_numbers = self.context.data_context.current_runs
     final_options = []
     for run in run_numbers:
         final_options += [
             wsName.get_raw_data_workspace_name(self.context, run_list_to_string(run), period=str(period + 1)) + " (PhaseQuad)"
             for period in range(self.context.data_context.num_periods(run))]
         for name in pair_names:
             final_options.append(
                 wsName.get_pair_data_workspace_name(self.context,
                                                     str(name),
                                                     run_list_to_string(run), not use_raw))
         for group_name in group_names:
             final_options.append(
                 wsName.get_group_asymmetry_name(self.context, str(group_name), run_list_to_string(run),
                                                 not use_raw))
     return final_options
示例#17
0
    def get_workspace_names_for_FFT_analysis(self, use_raw=True):
        pair_names = list(self.group_pair_context.pair_names)
        group_names = list(self.group_pair_context.group_names)
        run_numbers = self.data_context.current_runs
        workspace_options = []

        for run in run_numbers:
            workspace_options += self.phase_context.get_phase_quad(self.data_context.instrument, run_list_to_string(run))

            for name in pair_names:
                workspace_options.append(
                    wsName.get_pair_data_workspace_name(self,
                                                        str(name),
                                                        run_list_to_string(run), not use_raw))
            for group_name in group_names:
                workspace_options.append(
                    wsName.get_group_asymmetry_name(self, str(group_name), run_list_to_string(run),
                                                    not use_raw))
        return workspace_options
示例#18
0
 def set_run_edit_from_list(self, run_list):
     new_list = []
     for run_item in run_list:
         if isinstance(run_item, int):
             new_list += [run_item]
         elif isinstance(run_item, list):
             for run in run_item:
                 new_list += [run]
     run_string = run_utils.run_list_to_string(new_list)
     self._view.set_run_edit_text(run_string)
示例#19
0
 def set_run_edit_from_list(self, run_list):
     new_list = []
     for run_item in run_list:
         if isinstance(run_item, int):
             new_list += [run_item]
         elif isinstance(run_item, list):
             for run in run_item:
                 new_list += [run]
     run_string = run_utils.run_list_to_string(new_list)
     self._view.set_run_edit_text(run_string)
示例#20
0
    def getNPoints(self):
        run_numbers = self.context.data_context.current_runs
        ws = [wsName.get_raw_data_workspace_name(self.context, run_list_to_string(run_number)) for run_number in
              run_numbers]
        self.N_points = 1
        for name in ws:
            data = mantid.AnalysisDataService.retrieve(name)
            if self.N_points < len(data.readX(0)):
                self.N_points = len(data.readX(0))

        return self.N_points
示例#21
0
 def getWorkspaceNames(self):
     # get runs
     run_list = [run_list_to_string(run) for run in self.context.data_context.current_runs]
     self.view.addRuns(run_list)
     # get periods
     self._load_periods()
     # get min number of points as a power of 2
     start = int(
         math.ceil(math.log(self.context.data_context.num_points) / math.log(2.0)))
     values = [str(2**k) for k in range(start, 21)]
     self.view.addNPoints(values)
示例#22
0
 def run(self):
     try:
         # refer to the output of the loading widget (e.g. for co-adding)
         runs = run_list_to_string(self.current_run)
     except Exception:
         # extract from sample logs
         run_log = self.get_sample_log("run_number")
         if run_log:
             runs = run_log.value
         else:
             runs = 0
     return runs
示例#23
0
    def _calculate_counts_or_asymmetry(self,
                                       calculation_func,
                                       run,
                                       group,
                                       rebin=False):
        """Calculates the counts or asymmetry workspace depending on the 'calculation_func' that is provided."""
        run_as_string = run_list_to_string(run)
        periods_as_string = run_list_to_string(group.periods)

        # A user requirement is that processing can continue if a period is missing from some
        # of the runs. This filters out periods which are not in a given run.
        periods = [
            period for period in group.periods
            if period <= self.num_periods(run)
        ]

        if not periods:
            return None

        return calculation_func(run, group, periods, run_as_string,
                                periods_as_string, rebin)
示例#24
0
    def show_all_pairs(self):
        self.calculate_all_pairs()
        for run in self._data_context.current_runs:
            for pair_name in self._group_pair_context.pair_names:
                run_as_string = run_list_to_string(run)
                name = get_pair_data_workspace_name(self, pair_name, run_as_string, rebin=False)
                directory = get_base_data_directory(self, run_as_string) + get_pair_data_directory(self, run_as_string)

                self.group_pair_context[pair_name].show_raw(run, directory + name)

                if self._do_rebin():
                    name = get_pair_data_workspace_name(self, pair_name, run_as_string, rebin=True)
                    self.group_pair_context[pair_name].show_rebin(run, directory + name)
示例#25
0
 def getGroupedWorkspaceNames(self):
     run_numbers = self.data_context.current_runs
     runs = [
         wsName.get_raw_data_workspace_name(
             self.data_context.instrument,
             run_list_to_string(run_number),
             self.data_context.is_multi_period(),
             period=str(period + 1),
             workspace_suffix=self.workspace_suffix)
         for run_number in run_numbers
         for period in range(self.data_context.num_periods(run_number))
     ]
     return runs
示例#26
0
    def _calculate_phasequads(self, phasequad_obj, rebin):
        for run in self._data_context.current_runs:
            if self._data_context.num_periods(run) > 1:
                raise ValueError("Cannot support multiple periods")

            ws_list = self.calculate_phasequad(phasequad_obj, run, rebin)
            run_string = run_list_to_string(run)
            directory = get_base_data_directory(self, run_string)
            for ws in ws_list:
                muon_workspace_wrapper = MuonWorkspaceWrapper(directory + ws)
                muon_workspace_wrapper.show()

            phasequad_obj.update_asymmetry_workspaces(ws_list,
                                                      run,
                                                      rebin=rebin)
示例#27
0
    def calculate_group(self, group, run, rebin=False):
        run_as_string = run_list_to_string(run)
        periods_as_string = run_list_to_string(group.periods)

        # A user requirement is that processing can continue if a period is missing from some
        # of the runs. This filters out periods which are not in a given run.
        periods = [
            period for period in group.periods
            if period <= self.num_periods(run)
        ]

        # If not periods match return nothing here. The caller then needs to handle this gracefully.
        if not periods:
            return None, None, None

        name = get_group_data_workspace_name(self,
                                             group.name,
                                             run_as_string,
                                             periods_as_string,
                                             rebin=rebin)
        asym_name = get_group_asymmetry_name(self,
                                             group.name,
                                             run_as_string,
                                             periods_as_string,
                                             rebin=rebin)
        asym_name_unnorm = get_group_asymmetry_unnorm_name(self,
                                                           group.name,
                                                           run_as_string,
                                                           periods_as_string,
                                                           rebin=rebin)
        group_workspace = calculate_group_data(self, group, run, rebin, name,
                                               periods)
        group_asymmetry, group_asymmetry_unnormalised = estimate_group_asymmetry_data(
            self, group, run, rebin, asym_name, asym_name_unnorm, periods)

        return group_workspace, group_asymmetry, group_asymmetry_unnormalised
示例#28
0
    def show_raw_data(self):
        for run in self.data_context.current_runs:
            run_string = run_list_to_string(run)
            loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                'OutputWorkspace']
            directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string)

            if len(loaded_workspace) > 1:
                # Multi-period data
                for i, single_ws in enumerate(loaded_workspace):
                    name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1))
                    single_ws.show(name)
            else:
                # Single period data
                name = directory + get_raw_data_workspace_name(self, run_string)
                loaded_workspace[0].show(name)
示例#29
0
    def show_raw_data(self):
        for run in self.data_context.current_runs:
            run_string = run_list_to_string(run)
            loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                'OutputWorkspace']
            directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string)

            if len(loaded_workspace) > 1:
                # Multi-period data
                for i, single_ws in enumerate(loaded_workspace):
                    name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1))
                    single_ws.show(name)
            else:
                # Single period data
                name = directory + get_raw_data_workspace_name(self, run_string)
                loaded_workspace[0].show(name)
示例#30
0
    def get_names_of_time_domain_workspaces_to_fit(
            self, runs='', group_and_pair='', phasequad=False, rebin=False):
        group, pair = self.get_group_and_pair(group_and_pair)
        run_list = self.get_runs(runs)

        group_names = self.group_pair_context.get_group_workspace_names(
            run_list, group, rebin)
        pair_names = self.group_pair_context.get_pair_workspace_names(
            run_list, pair, rebin)

        phasequad_names = []
        if phasequad:
            for run in run_list:
                run_string = run_list_to_string(run)
                phasequad_names += self.phase_context.get_phase_quad(
                    self.data_context.instrument, run_string)
        return group_names + pair_names + phasequad_names
示例#31
0
    def show_raw_data(self):
        self.ads_observer.observeRename(False)
        for run in self.data_context.current_runs:
            with WorkspaceGroupDefinition():
                run_string = run_list_to_string(run)
                loaded_workspace = \
                    self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                        'OutputWorkspace']
                loaded_workspace_deadtime_table = self.data_context._loaded_data.get_data(
                    run=run, instrument=self.data_context.instrument
                )['workspace']['DataDeadTimeTable']
                directory = get_base_data_directory(self, run_string)

                deadtime_name = get_deadtime_data_workspace_name(
                    self.data_context.instrument,
                    str(run[0]),
                    workspace_suffix=self.workspace_suffix)
                MuonWorkspaceWrapper(loaded_workspace_deadtime_table).show(
                    directory + deadtime_name)
                self.data_context._loaded_data.get_data(
                    run=run, instrument=self.data_context.instrument
                )['workspace']['DataDeadTimeTable'] = deadtime_name

                if len(loaded_workspace) > 1:
                    # Multi-period data
                    for i, single_ws in enumerate(loaded_workspace):
                        name = directory + get_raw_data_workspace_name(
                            self.data_context.instrument,
                            run_string,
                            multi_period=True,
                            period=str(i + 1),
                            workspace_suffix=self.workspace_suffix)
                        single_ws.show(name)
                else:
                    # Single period data
                    name = directory + get_raw_data_workspace_name(
                        self.data_context.instrument,
                        run_string,
                        multi_period=False,
                        workspace_suffix=self.workspace_suffix)
                    loaded_workspace[0].show(name)

        self.ads_observer.observeRename(True)
示例#32
0
    def show_diff(self, run: list, diff: MuonDiff):
        diff_name = diff.name

        run_as_string = run_list_to_string(run)
        name = get_diff_asymmetry_name(self,
                                       diff_name,
                                       run_as_string,
                                       rebin=False)
        directory = get_base_data_directory(self, run_as_string)

        self.group_pair_context[diff_name].show_raw(run, directory + name)

        if self._do_rebin():
            name = get_diff_asymmetry_name(self,
                                           diff_name,
                                           run_as_string,
                                           rebin=True)
            self.group_pair_context[diff_name].show_rebin(
                run, directory + name)
示例#33
0
 def calculate_diff(self,
                    diff: MuonDiff,
                    run: List[int],
                    rebin: bool = False):
     try:
         positive_workspace_name = self._group_pair_context[
             diff.positive].get_asymmetry_workspace_for_run(run, rebin)
         negative_workspace_name = self._group_pair_context[
             diff.negative].get_asymmetry_workspace_for_run(run, rebin)
     except KeyError:
         # A key error here means the requested workspace does not exist so return None
         return None
     run_as_string = run_list_to_string(run)
     output_workspace_name = get_diff_asymmetry_name(self,
                                                     diff.name,
                                                     run_as_string,
                                                     rebin=rebin)
     return run_minus(positive_workspace_name, negative_workspace_name,
                      output_workspace_name)
示例#34
0
    def calculate_group(self, group_name, run, rebin=False):
        run_as_string = run_list_to_string(run)
        name = get_group_data_workspace_name(self,
                                             group_name,
                                             run_as_string,
                                             rebin=rebin)
        asym_name = get_group_asymmetry_name(self,
                                             group_name,
                                             run_as_string,
                                             rebin=rebin)
        asym_name_unnorm = get_group_asymmetry_unnorm_name(self,
                                                           group_name,
                                                           run_as_string,
                                                           rebin=rebin)
        group_workspace = calculate_group_data(self, group_name, run, rebin,
                                               name)
        group_asymmetry, group_asymmetry_unnormalised = estimate_group_asymmetry_data(
            self, group_name, run, rebin, asym_name, asym_name_unnorm)

        return group_workspace, group_asymmetry, group_asymmetry_unnormalised
示例#35
0
    def get_fit_workspace_names_from_groups_and_runs(self, runs,
                                                     groups_and_pairs):
        workspace_names = []
        for run in runs:
            for group_or_pair in groups_and_pairs:
                if group_or_pair in self.context.group_pair_context.selected_pairs:
                    workspace_names += [
                        get_pair_asymmetry_name(
                            self.context, group_or_pair, run,
                            not self.fitting_options["fit_to_raw"])
                    ]
                elif group_or_pair in self.context.group_pair_context.selected_groups:
                    period_string = run_list_to_string(
                        self.context.group_pair_context[group_or_pair].periods)
                    workspace_names += [
                        get_group_asymmetry_name(
                            self.context, group_or_pair, run, period_string,
                            not self.fitting_options["fit_to_raw"])
                    ]

        return workspace_names
示例#36
0
    def calculate_pair(self,
                       pair: MuonPair,
                       run: List[int],
                       rebin: bool = False):
        try:
            forward_group_workspace_name = self._group_pair_context[
                pair.forward_group].get_counts_workspace_for_run(run, rebin)
            backward_group_workspace_name = self._group_pair_context[
                pair.backward_group].get_counts_workspace_for_run(run, rebin)
        except KeyError:
            # A key error here means the requested workspace does not exist so return None
            return None

        run_as_string = run_list_to_string(run)
        output_workspace_name = get_pair_asymmetry_name(self,
                                                        pair.name,
                                                        run_as_string,
                                                        rebin=rebin)
        return calculate_pair_data(pair, forward_group_workspace_name,
                                   backward_group_workspace_name,
                                   output_workspace_name)
 def test_run_list_to_string_removes_duplicated_runs(self):
     run_list = [1, 1, 2, 2, 3, 4, 5, 3]
     run_string = utils.run_list_to_string(run_list)
     self.assertEqual(run_string, "1-5")
 def test_run_list_to_string_orders_run_numbers(self):
     run_list = [5, 3, 2, 4, 1]
     run_string = utils.run_list_to_string(run_list)
     self.assertEqual(run_string, "1-5")
 def test_run_list_to_string_removes_negative_runs(self):
     run_list = [-1, 1, 2, -2, 3, 4, 5, -3]
     run_string = utils.run_list_to_string(run_list)
     self.assertEqual(run_string, "1-5")
 def test_run_list_to_string_handles_non_consecutive_runs(self):
     run_lists = [[1, 3, 4, 5], [0, 1, 2, 3, 8, 9, 199, 200]]
     run_strings = ["1,3-5", "0-3,8-9,199-200"]
     for i in range(len(run_lists)):
         self.assertEqual(utils.run_list_to_string(run_lists[i]), run_strings[i])
 def test_run_list_to_string_orders_non_consecutive_runs(self):
     run_list = [50, 49, 48, 3, 2, 1]
     run_string = utils.run_list_to_string(run_list)
     self.assertEqual(run_string, "1-3,48-50")
 def test_run_list_to_string_throws_if_more_than_100_runs(self):
     run_list = [i for i in range(150)]
     with self.assertRaises(IndexError) as context:
         utils.run_list_to_string(run_list)
     self.assertTrue("Too many runs (150) must be <100" in str(context.exception))
示例#43
0
 def getGroupedWorkspaceNames(self):
     run_numbers = self.data_context.current_runs
     runs = [
         wsName.get_raw_data_workspace_name(self, run_list_to_string(run_number), period=str(period + 1))
         for run_number in run_numbers for period in range(self.data_context.num_periods(run_number))]
     return runs
 def test_run_list_to_string_for_consecutive_runs(self):
     run_list = [1, 2, 3, 4, 5]
     run_string = utils.run_list_to_string(run_list)
     self.assertEqual(run_string, "1-5")
 def add_group_to_view(self, group):
     self._view.disable_updates()
     assert isinstance(group, MuonGroup)
     entry = [str(group.name), run_utils.run_list_to_string(group.detectors, False), str(group.n_detectors)]
     self._view.add_entry_to_table(entry)
     self._view.enable_updates()