pypet/trajectory.py
def f_get_from_runs(self, name, include_default_run=True, use_indices=False,
                        fast_access=False, with_links = True,
                        shortcuts=True, max_depth=None, auto_load=False):
        """Searches for all occurrences of `name` in each run.

        Generates an ordered dictionary with the run names or indices as keys and
        found items as values.

        Example:

        >>> traj.f_get_from_runs(self, 'deep.universal_answer', use_indices=True, fast_access=True)
        OrderedDict([(0, 42), (1, 42), (2, 'fortytwo), (3, 43)])


        :param name:

            String description of the item(s) to find.
            Cannot be full names but the part of the names that are below
            a `run_XXXXXXXXX` group.

        :param include_default_run:

            If results found under ``run_ALL`` should be accounted for every run or simply be
            ignored.

        :param use_indices:

            If `True` the keys of the resulting dictionary are the run indices
            (e.g. 0,1,2,3), otherwise the keys are run names (e.g. `run_00000000`,
            `run_000000001`)

        :param fast_access:

            Whether to return parameter or result instances or the values handled by these.

        :param with_links:

            If links should be considered

        :param shortcuts:

            If shortcuts are allowed and the trajectory can *hop* over nodes in the
            path.

        :param max_depth:

            Maximum depth (relative to start node) how search should progress in tree.
            `None` means no depth limit.  Only relevant if `shortcuts` are allowed.

        :param auto_load:

            If data should be loaded from the storage service if it cannot be found in the
            current trajectory tree. Auto-loading will load group and leaf nodes currently
            not in memory and it will load data into empty leaves. Be aware that auto-loading
            does not work with shortcuts.

        :return:

            Ordered dictionary with run names or indices as keys and found items as values.
            Will only include runs where an item was actually found.

        """
        result_dict = OrderedDict()
        old_crun = self.v_crun

        try:

            if len(self._run_parent_groups) > 0:
                for run_name in self.f_iter_runs():
                    # Iterate over all runs
                    value = None
                    already_found = False
                    for run_parent_group in self._run_parent_groups.values():
                        if run_name not in run_parent_group._children:
                            continue

                        try:
                            value = run_parent_group.f_get(run_name + '.' + name,
                                                           fast_access=False,
                                                           with_links=with_links,
                                                           shortcuts=shortcuts,
                                                           max_depth=max_depth,
                                                           auto_load=auto_load)
                            if already_found:
                                raise pex.NotUniqueNodeError('`%s` has been found several times '
                                                             'in one run.' % name)
                            else:
                                already_found = True

                        except (AttributeError, pex.DataNotInStorageError):
                            pass

                    if value is None and include_default_run:
                        for run_parent_group in self._run_parent_groups.values():
                            try:
                                value = run_parent_group.f_get(self.f_wildcard('$', -1) +
                                                               '.' + name,
                                                               fast_access=False,
                                                               with_links=with_links,
                                                               shortcuts=shortcuts,
                                                               max_depth=max_depth,
                                                               auto_load=auto_load)
                                if already_found:
                                    raise pex.NotUniqueNodeError('`%s` has been found several '
                                                                 'times in one run.' % name)
                                else:
                                    already_found = True
                            except (AttributeError, pex.DataNotInStorageError):
                                pass

                    if value is not None:

                        if value.v_is_leaf:
                            value = self._nn_interface._apply_fast_access(value, fast_access)

                        if use_indices:
                            key = self.f_idx_to_run(run_name)
                        else:
                            key = run_name

                        result_dict[key] = value

            return result_dict
        finally:
            self.v_crun = old_crun
def f_get_from_runs(self, name, include_default_run=True, use_indices=False,
                        fast_access=False, with_links = True,
                        shortcuts=True, max_depth=None, auto_load=False):
        """Searches for all occurrences of `name` in each run.

        Generates an ordered dictionary with the run names or indices as keys and
        found items as values.

        Example:

        >>> traj.f_get_from_runs(self, 'deep.universal_answer', use_indices=True, fast_access=True)
        OrderedDict([(0, 42), (1, 42), (2, 'fortytwo), (3, 43)])


        :param name:

            String description of the item(s) to find.
            Cannot be full names but the part of the names that are below
            a `run_XXXXXXXXX` group.

        :param include_default_run:

            If results found under ``run_ALL`` should be accounted for every run or simply be
            ignored.

        :param use_indices:

            If `True` the keys of the resulting dictionary are the run indices
            (e.g. 0,1,2,3), otherwise the keys are run names (e.g. `run_00000000`,
            `run_000000001`)

        :param fast_access:

            Whether to return parameter or result instances or the values handled by these.

        :param with_links:

            If links should be considered

        :param shortcuts:

            If shortcuts are allowed and the trajectory can *hop* over nodes in the
            path.

        :param max_depth:

            Maximum depth (relative to start node) how search should progress in tree.
            `None` means no depth limit.  Only relevant if `shortcuts` are allowed.

        :param auto_load:

            If data should be loaded from the storage service if it cannot be found in the
            current trajectory tree. Auto-loading will load group and leaf nodes currently
            not in memory and it will load data into empty leaves. Be aware that auto-loading
            does not work with shortcuts.

        :return:

            Ordered dictionary with run names or indices as keys and found items as values.
            Will only include runs where an item was actually found.

        """
        result_dict = OrderedDict()
        old_crun = self.v_crun

        try:

            if len(self._run_parent_groups) > 0:
                for run_name in self.f_iter_runs():
                    # Iterate over all runs
                    value = None
                    already_found = False
                    for run_parent_group in self._run_parent_groups.values():
                        if run_name not in run_parent_group._children:
                            continue

                        try:
                            value = run_parent_group.f_get(run_name + '.' + name,
                                                           fast_access=False,
                                                           with_links=with_links,
                                                           shortcuts=shortcuts,
                                                           max_depth=max_depth,
                                                           auto_load=auto_load)
                            if already_found:
                                raise pex.NotUniqueNodeError('`%s` has been found several times '
                                                             'in one run.' % name)
                            else:
                                already_found = True

                        except (AttributeError, pex.DataNotInStorageError):
                            pass

                    if value is None and include_default_run:
                        for run_parent_group in self._run_parent_groups.values():
                            try:
                                value = run_parent_group.f_get(self.f_wildcard('$', -1) +
                                                               '.' + name,
                                                               fast_access=False,
                                                               with_links=with_links,
                                                               shortcuts=shortcuts,
                                                               max_depth=max_depth,
                                                               auto_load=auto_load)
                                if already_found:
                                    raise pex.NotUniqueNodeError('`%s` has been found several '
                                                                 'times in one run.' % name)
                                else:
                                    already_found = True
                            except (AttributeError, pex.DataNotInStorageError):
                                pass

                    if value is not None:

                        if value.v_is_leaf:
                            value = self._nn_interface._apply_fast_access(value, fast_access)

                        if use_indices:
                            key = self.f_idx_to_run(run_name)
                        else:
                            key = run_name

                        result_dict[key] = value

            return result_dict
        finally:
            self.v_crun = old_crun
Searches for all occurrences of `name` in each run.

        Generates an ordered dictionary with the run names or indices as keys and
        found items as values.

        Example:

        >>> traj.f_get_from_runs(self, 'deep.universal_answer', use_indices=True, fast_access=True)
        OrderedDict([(0, 42), (1, 42), (2, 'fortytwo), (3, 43)])


        :param name:

            String description of the item(s) to find.
            Cannot be full names but the part of the names that are below
            a `run_XXXXXXXXX` group.

        :param include_default_run:

            If results found under ``run_ALL`` should be accounted for every run or simply be
            ignored.

        :param use_indices:

            If `True` the keys of the resulting dictionary are the run indices
            (e.g. 0,1,2,3), otherwise the keys are run names (e.g. `run_00000000`,
            `run_000000001`)

        :param fast_access:

            Whether to return parameter or result instances or the values handled by these.

        :param with_links:

            If links should be considered

        :param shortcuts:

            If shortcuts are allowed and the trajectory can *hop* over nodes in the
            path.

        :param max_depth:

            Maximum depth (relative to start node) how search should progress in tree.
            `None` means no depth limit.  Only relevant if `shortcuts` are allowed.

        :param auto_load:

            If data should be loaded from the storage service if it cannot be found in the
            current trajectory tree. Auto-loading will load group and leaf nodes currently
            not in memory and it will load data into empty leaves. Be aware that auto-loading
            does not work with shortcuts.

        :return:

            Ordered dictionary with run names or indices as keys and found items as values.
            Will only include runs where an item was actually found.