pypet/naturalnaming.py
def _add_prefix(self, split_names, start_node, group_type_name):
        """Adds the correct sub branch prefix to a given name.

        Usually the prefix is the full name of the parent node. In case items are added
        directly to the trajectory the prefixes are chosen according to the matching subbranch.

        For example, this could be 'parameters' for parameters or 'results.run_00000004' for
        results added to the fifth single run.

        :param split_names:

            List of names of the new node (e.g. ``['mynewgroupA', 'mynewgroupB', 'myresult']``).

        :param start_node:

            Parent node under which the new node should be added.

        :param group_type_name:

            Type name of subbranch the item belongs to
            (e.g. 'PARAMETER_GROUP', 'RESULT_GROUP' etc).


        :return: The name with the added prefix.

        """
        root = self._root_instance

        # If the start node of our insertion is root or one below root
        # we might need to add prefixes.
        # In case of derived parameters and results we also need to add prefixes containing the
        # subbranch and the current run in case of a single run.
        # For instance, a prefix could be 'results.runs.run_00000007'.
        prepend = []
        if start_node.v_depth < 3 and not group_type_name == GROUP:
            if start_node.v_depth == 0:

                if group_type_name == DERIVED_PARAMETER_GROUP:
                    if split_names[0] == 'derived_parameters':
                        return split_names
                    else:
                        prepend += ['derived_parameters']

                elif group_type_name == RESULT_GROUP:
                    if split_names[0] == 'results':
                        return split_names
                    else:
                        prepend += ['results']

                elif group_type_name == CONFIG_GROUP:
                    if split_names[0] == 'config':
                        return split_names
                    else:
                        prepend += ['config']

                elif group_type_name == PARAMETER_GROUP:
                    if split_names[0] == 'parameters':
                        return split_names[0]
                    else:
                        prepend += ['parameters']
                else:
                    raise RuntimeError('Why are you here?')

            # Check if we have to add a prefix containing the current run
            if root._is_run and root._auto_run_prepend:
                dummy = root.f_wildcard('$', -1)
                crun = root.f_wildcard('$')
                if any(name in root._run_information for name in split_names):
                    pass
                elif any(name == dummy for name in split_names):
                    pass
                elif (group_type_name == RESULT_GROUP or
                        group_type_name == DERIVED_PARAMETER_GROUP):

                    if start_node.v_depth == 0:
                        prepend += ['runs', crun]

                    elif start_node.v_depth == 1:

                        if len(split_names) == 1 and split_names[0] == 'runs':
                            return split_names
                        else:
                            prepend += ['runs', crun]

                    elif start_node.v_depth == 2 and start_node.v_name == 'runs':
                        prepend += [crun]

        if prepend:
            split_names = prepend + split_names

        return split_names
def _add_prefix(self, split_names, start_node, group_type_name):
        root = self._root_instance

        # If the start node of our insertion is root or one below root
        # we might need to add prefixes.
        # In case of derived parameters and results we also need to add prefixes containing the
        # subbranch and the current run in case of a single run.
        # For instance, a prefix could be 'results.runs.run_00000007'.
        prepend = []
        if start_node.v_depth < 3 and not group_type_name == GROUP:
            if start_node.v_depth == 0:

                if group_type_name == DERIVED_PARAMETER_GROUP:
                    if split_names[0] == 'derived_parameters':
                        return split_names
                    else:
                        prepend += ['derived_parameters']

                elif group_type_name == RESULT_GROUP:
                    if split_names[0] == 'results':
                        return split_names
                    else:
                        prepend += ['results']

                elif group_type_name == CONFIG_GROUP:
                    if split_names[0] == 'config':
                        return split_names
                    else:
                        prepend += ['config']

                elif group_type_name == PARAMETER_GROUP:
                    if split_names[0] == 'parameters':
                        return split_names[0]
                    else:
                        prepend += ['parameters']
                else:
                    raise RuntimeError('Why are you here?')

            # Check if we have to add a prefix containing the current run
            if root._is_run and root._auto_run_prepend:
                dummy = root.f_wildcard('$', -1)
                crun = root.f_wildcard('$')
                if any(name in root._run_information for name in split_names):
                    pass
                elif any(name == dummy for name in split_names):
                    pass
                elif (group_type_name == RESULT_GROUP or
                        group_type_name == DERIVED_PARAMETER_GROUP):

                    if start_node.v_depth == 0:
                        prepend += ['runs', crun]

                    elif start_node.v_depth == 1:

                        if len(split_names) == 1 and split_names[0] == 'runs':
                            return split_names
                        else:
                            prepend += ['runs', crun]

                    elif start_node.v_depth == 2 and start_node.v_name == 'runs':
                        prepend += [crun]

        if prepend:
            split_names = prepend + split_names

        return split_names
def _add_prefix ( self , split_names , start_node , group_type_name ) : root = self . _root_instance # If the start node of our insertion is root or one below root # we might need to add prefixes. # In case of derived parameters and results we also need to add prefixes containing the # subbranch and the current run in case of a single run. # For instance, a prefix could be 'results.runs.run_00000007'. prepend = [ ] if start_node . v_depth < 3 and not group_type_name == GROUP : if start_node . v_depth == 0 : if group_type_name == DERIVED_PARAMETER_GROUP : if split_names [ 0 ] == 'derived_parameters' : return split_names else : prepend += [ 'derived_parameters' ] elif group_type_name == RESULT_GROUP : if split_names [ 0 ] == 'results' : return split_names else : prepend += [ 'results' ] elif group_type_name == CONFIG_GROUP : if split_names [ 0 ] == 'config' : return split_names else : prepend += [ 'config' ] elif group_type_name == PARAMETER_GROUP : if split_names [ 0 ] == 'parameters' : return split_names [ 0 ] else : prepend += [ 'parameters' ] else : raise RuntimeError ( 'Why are you here?' ) # Check if we have to add a prefix containing the current run if root . _is_run and root . _auto_run_prepend : dummy = root . f_wildcard ( '$' , - 1 ) crun = root . f_wildcard ( '$' ) if any ( name in root . _run_information for name in split_names ) : pass elif any ( name == dummy for name in split_names ) : pass elif ( group_type_name == RESULT_GROUP or group_type_name == DERIVED_PARAMETER_GROUP ) : if start_node . v_depth == 0 : prepend += [ 'runs' , crun ] elif start_node . v_depth == 1 : if len ( split_names ) == 1 and split_names [ 0 ] == 'runs' : return split_names else : prepend += [ 'runs' , crun ] elif start_node . v_depth == 2 and start_node . v_name == 'runs' : prepend += [ crun ] if prepend : split_names = prepend + split_names return split_names
Adds the correct sub branch prefix to a given name.

        Usually the prefix is the full name of the parent node. In case items are added
        directly to the trajectory the prefixes are chosen according to the matching subbranch.

        For example, this could be 'parameters' for parameters or 'results.run_00000004' for
        results added to the fifth single run.

        :param split_names:

            List of names of the new node (e.g. ``['mynewgroupA', 'mynewgroupB', 'myresult']``).

        :param start_node:

            Parent node under which the new node should be added.

        :param group_type_name:

            Type name of subbranch the item belongs to
            (e.g. 'PARAMETER_GROUP', 'RESULT_GROUP' etc).


        :return: The name with the added prefix.
Adds the correct sub branch prefix to a given name .