pypet/trajectory.py
def f_copy(self, copy_leaves=True,
                     with_links=True):
        """Returns a *shallow* copy of a trajectory.

        :param copy_leaves:

            If leaves should be **shallow** copied or simply referred to by both trees.
            **Shallow** copying is established using the copy module.

            Accepts the setting ``'explored'`` to only copy explored parameters.
            Note that ``v_full_copy`` determines how these will be copied.

        :param with_links: If links should be ignored or followed and copied as well

        :return: A shallow copy

        """
        new_traj = Trajectory(_copy_traj=True)

        new_traj._length = self._length
        new_traj._name = self._name

        new_traj._timestamp = self._timestamp
        new_traj._time = self._time

        new_traj._single_run_ids = self._single_run_ids
        new_traj._run_information = self._run_information
        new_traj._updated_run_information = self._updated_run_information

        new_traj._fast_access = self._fast_access
        new_traj._shortcuts = self._shortcuts
        new_traj._iter_recursive = self._iter_recursive
        new_traj._max_depth = self._max_depth
        new_traj._auto_load = self._auto_load
        new_traj._with_links = self._with_links

        new_traj._environment_hexsha = self._environment_hexsha
        new_traj._environment_name = self._environment_name

        # Index of a trajectory is -1, if the trajectory should behave like a single run
        # and blind out other single run results, this can be changed via 'v_crun'.
        new_traj._idx = self._idx
        new_traj._crun = self._crun

        new_traj._standard_parameter = self._standard_parameter
        new_traj._standard_result = self._standard_result
        new_traj._standard_leaf = self._standard_leaf

        new_traj._auto_run_prepend = self._auto_run_prepend
        new_traj._no_clobber = self._no_clobber

        new_traj._run_started = self._run_started # For manually using a trajectory
        new_traj._run_by_environment = self._run_by_environment  # To disable manual running of experiment

        new_traj._full_copy = self._full_copy

        new_traj._dynamic_imports = self._dynamic_imports

        new_traj._wildcard_functions = self._wildcard_functions
        new_traj._wildcard_keys = self._wildcard_keys
        new_traj._reversed_wildcards = self._reversed_wildcards
        new_traj._wildcard_cache = self._wildcard_cache

        new_traj._comment = self._comment

        new_traj._stored = self._stored

        new_traj._storage_service = self._storage_service

        new_traj._is_run = self._is_run

        new_traj._copy_from(self, copy_leaves=copy_leaves,
                                   with_links=with_links)

        # Copy references to new nodes and leaves
        for my_dict, new_dict in ((self._new_nodes, new_traj._new_nodes),
                                 (self._new_links, new_traj._new_links)):
            for key in my_dict:
                value = my_dict[key]
                parent, child = value
                if parent is self:
                    new_parent = new_traj
                else:
                    new_parent = new_traj.f_get(parent.v_full_name,
                                            shortcuts=False,
                                            with_links=False,
                                            auto_load=False)
                new_child = new_parent._children[key[1]]
                new_dict[key] = (new_parent, new_child)

        return new_traj
def f_copy(self, copy_leaves=True,
                     with_links=True):
        """Returns a *shallow* copy of a trajectory.

        :param copy_leaves:

            If leaves should be **shallow** copied or simply referred to by both trees.
            **Shallow** copying is established using the copy module.

            Accepts the setting ``'explored'`` to only copy explored parameters.
            Note that ``v_full_copy`` determines how these will be copied.

        :param with_links: If links should be ignored or followed and copied as well

        :return: A shallow copy

        """
        new_traj = Trajectory(_copy_traj=True)

        new_traj._length = self._length
        new_traj._name = self._name

        new_traj._timestamp = self._timestamp
        new_traj._time = self._time

        new_traj._single_run_ids = self._single_run_ids
        new_traj._run_information = self._run_information
        new_traj._updated_run_information = self._updated_run_information

        new_traj._fast_access = self._fast_access
        new_traj._shortcuts = self._shortcuts
        new_traj._iter_recursive = self._iter_recursive
        new_traj._max_depth = self._max_depth
        new_traj._auto_load = self._auto_load
        new_traj._with_links = self._with_links

        new_traj._environment_hexsha = self._environment_hexsha
        new_traj._environment_name = self._environment_name

        # Index of a trajectory is -1, if the trajectory should behave like a single run
        # and blind out other single run results, this can be changed via 'v_crun'.
        new_traj._idx = self._idx
        new_traj._crun = self._crun

        new_traj._standard_parameter = self._standard_parameter
        new_traj._standard_result = self._standard_result
        new_traj._standard_leaf = self._standard_leaf

        new_traj._auto_run_prepend = self._auto_run_prepend
        new_traj._no_clobber = self._no_clobber

        new_traj._run_started = self._run_started # For manually using a trajectory
        new_traj._run_by_environment = self._run_by_environment  # To disable manual running of experiment

        new_traj._full_copy = self._full_copy

        new_traj._dynamic_imports = self._dynamic_imports

        new_traj._wildcard_functions = self._wildcard_functions
        new_traj._wildcard_keys = self._wildcard_keys
        new_traj._reversed_wildcards = self._reversed_wildcards
        new_traj._wildcard_cache = self._wildcard_cache

        new_traj._comment = self._comment

        new_traj._stored = self._stored

        new_traj._storage_service = self._storage_service

        new_traj._is_run = self._is_run

        new_traj._copy_from(self, copy_leaves=copy_leaves,
                                   with_links=with_links)

        # Copy references to new nodes and leaves
        for my_dict, new_dict in ((self._new_nodes, new_traj._new_nodes),
                                 (self._new_links, new_traj._new_links)):
            for key in my_dict:
                value = my_dict[key]
                parent, child = value
                if parent is self:
                    new_parent = new_traj
                else:
                    new_parent = new_traj.f_get(parent.v_full_name,
                                            shortcuts=False,
                                            with_links=False,
                                            auto_load=False)
                new_child = new_parent._children[key[1]]
                new_dict[key] = (new_parent, new_child)

        return new_traj
Returns a *shallow* copy of a trajectory.

        :param copy_leaves:

            If leaves should be **shallow** copied or simply referred to by both trees.
            **Shallow** copying is established using the copy module.

            Accepts the setting ``'explored'`` to only copy explored parameters.
            Note that ``v_full_copy`` determines how these will be copied.

        :param with_links: If links should be ignored or followed and copied as well

        :return: A shallow copy