param_dict['<STR_LIT>'] = {}<EOL>param_dict['<STR_LIT>'] = {}<EOL>param_dict['<STR_LIT>'] ={}<EOL>param_dict['<STR_LIT>'] = {}<EOL>param_dict['<STR_LIT>'] = {}<EOL>param_dict['<STR_LIT>'] ={}<EOL>param_dict['<STR_LIT>'] ={}<EOL>param_dict['<STR_LIT>']={}<EOL>normal_dict = param_dict['<STR_LIT>']<EOL>normal_dict['<STR_LIT:string>'] = '<STR_LIT>'<EOL>normal_dict['<STR_LIT:int>'] = <NUM_LIT><EOL>normal_dict['<STR_LIT>'] = <NUM_LIT><EOL>normal_dict['<STR_LIT>'] = <NUM_LIT><EOL>normal_dict['<STR_LIT:bool>'] =True<EOL>normal_dict['<STR_LIT>'] = <NUM_LIT:0><EOL>numpy_dict=param_dict['<STR_LIT>']<EOL>numpy_dict['<STR_LIT:string>'] = np.array(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>numpy_dict['<STR_LIT:int>'] = np.array([<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>,<NUM_LIT:4>])<EOL>numpy_dict['<STR_LIT>'] = np.array([<NUM_LIT:1.0>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>])<EOL>numpy_dict['<STR_LIT:bool>'] = np.array([True, False, True])<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = np.matrix([[<NUM_LIT:1.0>,<NUM_LIT>],[<NUM_LIT>,<NUM_LIT>]])<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = np.array([[[<NUM_LIT:1.0>,<NUM_LIT>],[<NUM_LIT>,<NUM_LIT>]],[[<NUM_LIT>,-<NUM_LIT>],[<NUM_LIT>,<NUM_LIT>]]])<EOL>spsparse_csc = spsp.lil_matrix((<NUM_LIT>,<NUM_LIT>))<EOL>spsparse_csc[<NUM_LIT:1>,<NUM_LIT:2>] = <NUM_LIT><EOL>spsparse_csc[<NUM_LIT:1>,<NUM_LIT:9>] = <NUM_LIT><EOL>spsparse_csc = spsparse_csc.tocsc()<EOL>spsparse_csr = spsp.lil_matrix((<NUM_LIT>,<NUM_LIT>))<EOL>spsparse_csr[<NUM_LIT:1>,<NUM_LIT:3>] = <NUM_LIT><EOL>spsparse_csr[<NUM_LIT>,<NUM_LIT>] = <NUM_LIT><EOL>spsparse_csr = spsparse_csr.tocsr()<EOL>spsparse_bsr = spsp.bsr_matrix(np.matrix([[<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:2>],<EOL>[<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:2>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:3>, <NUM_LIT:3>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:3>, <NUM_LIT:3>],<EOL>[<NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:5>, <NUM_LIT:6>, <NUM_LIT:6>],<EOL>[<NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:5>, <NUM_LIT:6>, <NUM_LIT:6>]]))<EOL>spsparse_dia = spsp.dia_matrix(np.matrix([[<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:3>, <NUM_LIT:0>],<EOL>[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:0>, <NUM_LIT:4>],<EOL>[<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:3>, <NUM_LIT:4>]]))<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = spsparse_bsr<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = spsparse_csc<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = spsparse_csr<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = spsparse_dia<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = ()<EOL>param_dict['<STR_LIT>']['<STR_LIT:int>'] = (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>)<EOL>param_dict['<STR_LIT>']['<STR_LIT:float>'] = (<NUM_LIT>,<NUM_LIT>,<NUM_LIT>)<EOL>param_dict['<STR_LIT>']['<STR_LIT:str>'] = ('<STR_LIT:1>','<STR_LIT>','<STR_LIT>')<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = []<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = [<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>]<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = [<NUM_LIT>,<NUM_LIT>,<NUM_LIT>]<EOL>param_dict['<STR_LIT>']['<STR_LIT>'] = ['<STR_LIT:1>','<STR_LIT>','<STR_LIT>']<EOL>param_dict['<STR_LIT>']['<STR_LIT:list>']= ['<STR_LIT:b>','<STR_LIT:h>', <NUM_LIT>, (), <NUM_LIT:0>]<EOL>param_dict['<STR_LIT>']['<STR_LIT:list>']= ['<STR_LIT:b>','<STR_LIT:h>', <NUM_LIT>, (), <NUM_LIT:1>]<EOL>param_dict['<STR_LIT>']['<STR_LIT:list>']= ['<STR_LIT:b>',[<NUM_LIT>,<NUM_LIT>], <NUM_LIT>, (),<NUM_LIT:2>]<EOL>

Fills a dictionary with some parameters that can be put into a trajectory.


root = logging.getLogger()<EOL>for logger in list(root.manager.loggerDict.values()) + [root]:<EOL><INDENT>if hasattr(logger, '<STR_LIT>'):<EOL><INDENT>handlers = logger.handlers<EOL>for handler in handlers:<EOL><INDENT>if hasattr(handler, '<STR_LIT>'):<EOL><INDENT>handler.flush()<EOL><DEDENT>if hasattr(handler, '<STR_LIT>'):<EOL><INDENT>handler.close()<EOL><DEDENT><DEDENT>logger.handlers = []<EOL><DEDENT><DEDENT>sys.stdout = sys.__stdout__<EOL>sys.stderr = sys.__stderr__<EOL>

Deletes all handlers and closes all log-files


<EOL>new_filename = None<EOL>try:<EOL><INDENT>new_filename = prepend_mpl_import(filename)<EOL>retcode = subprocess.call(sys.executable + '<STR_LIT:U+0020>' + new_filename, shell=True)<EOL>if retcode != <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>' % filename)<EOL>sys.exit(retcode)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if new_filename is not None:<EOL><INDENT>os.remove(new_filename)<EOL><DEDENT><DEDENT>

Executes a file as script.

    First prepends matplotlib import


def _prm_add_meta_info(self, instance, group, overwrite=False):

if overwrite:<EOL><INDENT>flags = ()<EOL><DEDENT>else:<EOL><INDENT>flags = (HDF5StorageService.ADD_ROW,)<EOL><DEDENT>definitely_store_comment = True<EOL>try:<EOL><INDENT>definitely_store_comment = self._prm_meta_add_summary(instance)<EOL>try:<EOL><INDENT>table_name = instance.v_branch + '<STR_LIT>'<EOL>table = getattr(self._overview_group, table_name)<EOL>if len(table) < pypetconstants.HDF5_MAX_OVERVIEW_TABLE_LENGTH:<EOL><INDENT>self._all_store_param_or_result_table_entry(instance, table,<EOL>flags=flags)<EOL><DEDENT><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>except Exception as exc:<EOL><INDENT>self._logger.error('<STR_LIT>' % repr(exc))<EOL><DEDENT>if ((not self._purge_duplicate_comments or definitely_store_comment) and<EOL>instance.v_comment != '<STR_LIT>'):<EOL><INDENT>setattr(group._v_attrs, HDF5StorageService.COMMENT, instance.v_comment)<EOL><DEDENT>setattr(group._v_attrs, HDF5StorageService.CLASS_NAME, instance.f_get_class_name())<EOL>setattr(group._v_attrs, HDF5StorageService.LEAF, True)<EOL>if instance.v_is_parameter and instance.v_explored:<EOL><INDENT>try:<EOL><INDENT>tablename = '<STR_LIT>'<EOL>table = getattr(self._overview_group, tablename)<EOL>if len(table) < pypetconstants.HDF5_MAX_OVERVIEW_TABLE_LENGTH:<EOL><INDENT>self._all_store_param_or_result_table_entry(instance, table,<EOL>flags=flags)<EOL><DEDENT><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>pass<EOL><DEDENT>except Exception as exc:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>' % repr(exc))<EOL><DEDENT><DEDENT>

Adds information to overview tables and meta information to
        the `instance`s hdf5 `group`.

        :param instance: Instance to store meta info about
        :param group: HDF5 group of instance
        :param overwrite: If data should be explicitly overwritten


def _prm_write_into_other_array(self, key, data, group, fullname,<EOL>flag, **kwargs):

try:<EOL><INDENT>if flag == HDF5StorageService.CARRAY:<EOL><INDENT>factory = self._hdf5file.create_carray<EOL><DEDENT>elif flag == HDF5StorageService.EARRAY:<EOL><INDENT>factory = self._hdf5file.create_earray<EOL><DEDENT>elif flag == HDF5StorageService.VLARRAY:<EOL><INDENT>factory = self._hdf5file.create_vlarray<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if key in group:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>filters = kwargs.pop('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>filters = self._all_get_filters(kwargs)<EOL><DEDENT>try:<EOL><INDENT>other_array = factory(where=group, name=key, obj=data,<EOL>filters=filters, **kwargs)<EOL><DEDENT>except (ValueError, TypeError) as exc:<EOL><INDENT>try:<EOL><INDENT>conv_data = data[:]<EOL>conv_data = np.core.defchararray.encode(conv_data, self.encoding)<EOL>other_array = factory(where=group, name=key,<EOL>obj=conv_data,<EOL>filters=filters, **kwargs)<EOL><DEDENT>except Exception:<EOL><INDENT>raise exc<EOL><DEDENT><DEDENT>if data is not None:<EOL><INDENT>self._all_set_attributes_to_recall_natives(data, other_array,<EOL>HDF5StorageService.DATA_PREFIX)<EOL><DEDENT>setattr(other_array._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)<EOL>self._hdf5file.flush()<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>' % (flag, key, fullname))<EOL>raise<EOL><DEDENT>

Stores data as carray, earray or vlarray depending on `flag`.

        :param key:

            Name of data item to store

        :param data:

            Data to store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param recall:

            If container type and data type for perfect recall should be stored

        :param flag:

            How to store:
                CARRAY, EARRAY, VLARRAY


translated_name = '<STR_LIT:/>' + self._trajectory_name + '<STR_LIT:/>' + link_name.replace('<STR_LIT:.>','<STR_LIT:/>')<EOL>link = self._hdf5file.get_node(where=translated_name)<EOL>link._f_remove()<EOL>


def _ann_store_annotations(self, item_with_annotations, node, overwrite=False):

<EOL>if overwrite is True or overwrite == '<STR_LIT>':<EOL><INDENT>annotated = self._all_get_from_attrs(node, HDF5StorageService.ANNOTATED)<EOL>if annotated:<EOL><INDENT>current_attrs = node._v_attrs<EOL>for attr_name in current_attrs._v_attrnames:<EOL><INDENT>if attr_name.startswith(HDF5StorageService.ANNOTATION_PREFIX):<EOL><INDENT>delattr(current_attrs, attr_name)<EOL><DEDENT><DEDENT>delattr(current_attrs, HDF5StorageService.ANNOTATED)<EOL>self._hdf5file.flush()<EOL><DEDENT><DEDENT>if not item_with_annotations.v_annotations.f_is_empty():<EOL><INDENT>anno_dict = item_with_annotations.v_annotations._dict<EOL>current_attrs = node._v_attrs<EOL>changed = False<EOL>for field_name in anno_dict:<EOL><INDENT>val = anno_dict[field_name]<EOL>field_name_with_prefix = HDF5StorageService.ANNOTATION_PREFIX + field_name<EOL>if field_name_with_prefix not in current_attrs:<EOL><INDENT>setattr(current_attrs, field_name_with_prefix, val)<EOL>changed = True<EOL><DEDENT><DEDENT>if changed:<EOL><INDENT>setattr(current_attrs, HDF5StorageService.ANNOTATED, True)<EOL>self._hdf5file.flush()<EOL><DEDENT><DEDENT>


maxlength = <NUM_LIT:1><EOL>for stringar in string_list:<EOL><INDENT>if isinstance(stringar, np.ndarray):<EOL><INDENT>if stringar.ndim > <NUM_LIT:0>:<EOL><INDENT>for string in stringar.ravel():<EOL><INDENT>maxlength = max(len(string), maxlength)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>maxlength = max(len(stringar.tolist()), maxlength)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>maxlength = max(len(stringar), maxlength)<EOL><DEDENT><DEDENT>return int(maxlength * <NUM_LIT>)<EOL>

Returns the longest string size for a string entry across data.


def _prm_write_pandas_data(self, key, data, group, fullname, flag, **kwargs):

try:<EOL><INDENT>if '<STR_LIT>' not in kwargs:<EOL><INDENT>filters = self._all_get_filters(kwargs)<EOL>kwargs['<STR_LIT>'] = filters<EOL><DEDENT>if '<STR_LIT>' not in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = self.pandas_format<EOL><DEDENT>if '<STR_LIT>' not in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = self.encoding<EOL><DEDENT>overwrite = kwargs.pop('<STR_LIT>', False)<EOL>if key in group and not (overwrite or kwargs.get('<STR_LIT>', False)):<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (key, fullname))<EOL><DEDENT>else:<EOL><INDENT>self._logger.debug('<STR_LIT>' % (key, fullname))<EOL><DEDENT>if data is not None and (kwargs['<STR_LIT>'] == '<STR_LIT:f>' or kwargs['<STR_LIT>'] == '<STR_LIT>'):<EOL><INDENT>kwargs['<STR_LIT>'] = data.shape[<NUM_LIT:0>]<EOL><DEDENT>name = group._v_pathname + '<STR_LIT:/>' + key<EOL>self._hdf5store.put(name, data, **kwargs)<EOL>self._hdf5store.flush()<EOL>self._hdf5file.flush()<EOL>frame_group = group._f_get_child(key)<EOL>setattr(frame_group._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)<EOL>self._hdf5file.flush()<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>' % (key, fullname))<EOL>raise<EOL><DEDENT>

Stores a pandas DataFrame into hdf5.

        :param key:

            Name of data item to store

        :param data:

            Pandas Data to Store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param flag:

            If it is a series, frame or panel


def _trj_merge_trajectories(self, other_trajectory_name, rename_dict, move_nodes=False,<EOL>delete_trajectory=False, other_filename=None):

if other_filename is None or other_filename == self.filename:<EOL><INDENT>other_filename = self.filename<EOL>other_file = self._hdf5file<EOL>other_is_different = False<EOL><DEDENT>else:<EOL><INDENT>other_file = pt.open_file(filename=other_filename, mode='<STR_LIT>')<EOL>other_is_different = True<EOL><DEDENT>try:<EOL><INDENT>if not '<STR_LIT:/>' + other_trajectory_name in other_file:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (self._trajectory_name,<EOL>other_trajectory_name,<EOL>other_filename))<EOL><DEDENT>for old_name in rename_dict:<EOL><INDENT>new_name = rename_dict[old_name]<EOL>split_name = old_name.split('<STR_LIT:.>')<EOL>old_location = '<STR_LIT:/>' + other_trajectory_name + '<STR_LIT:/>' + '<STR_LIT:/>'.join(split_name)<EOL>split_name = new_name.split('<STR_LIT:.>')<EOL>new_parent_location = '<STR_LIT:/>' + self._trajectory_name + '<STR_LIT:/>' + '<STR_LIT:/>'.join(split_name[:-<NUM_LIT:1>])<EOL>new_short_name = split_name[-<NUM_LIT:1>]<EOL>old_node = other_file.get_node(old_location)<EOL>if move_nodes:<EOL><INDENT>self._hdf5file.move_node( where=old_node, newparent=new_parent_location,<EOL>newname=new_short_name, createparents=True)<EOL><DEDENT>else:<EOL><INDENT>if other_is_different:<EOL><INDENT>new_parent_dot_location = '<STR_LIT:.>'.join(split_name[:-<NUM_LIT:1>])<EOL>new_parent_or_loc, _ = self._all_create_or_get_groups(<EOL>new_parent_dot_location)<EOL>create_parents = False<EOL><DEDENT>else:<EOL><INDENT>new_parent_or_loc = new_parent_location<EOL>create_parents = True<EOL><DEDENT>self._hdf5file.copy_node(where=old_node, newparent=new_parent_or_loc,<EOL>newname=new_short_name, createparents=create_parents,<EOL>recursive=True)<EOL><DEDENT><DEDENT>if delete_trajectory:<EOL><INDENT>other_file.remove_node(where='<STR_LIT:/>', name=other_trajectory_name, recursive=True)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if other_is_different:<EOL><INDENT>other_file.flush()<EOL>other_file.close()<EOL><DEDENT><DEDENT>

Merges another trajectory into the current trajectory (as in self._trajectory_name).

        :param other_trajectory_name: Name of other trajectory
        :param rename_dict: Dictionary with old names (keys) and new names (values).
        :param move_nodes: Whether to move hdf5 nodes or copy them
        :param delete_trajectory: Whether to delete the other trajectory


def _all_add_or_modify_row(self, item_name, insert_dict, table, index=None, condition=None,<EOL>condvars=None,<EOL>flags=(ADD_ROW, MODIFY_ROW,)):

if len(flags) == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if index is not None and condition is not None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif condition is not None:<EOL><INDENT>row_iterator = table.where(condition, condvars=condvars)<EOL><DEDENT>elif index is not None:<EOL><INDENT>row_iterator = table.iterrows(index, index + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>row_iterator = None<EOL><DEDENT>try:<EOL><INDENT>row = next(row_iterator)<EOL><DEDENT>except TypeError:<EOL><INDENT>row = None<EOL><DEDENT>except StopIteration:<EOL><INDENT>row = None<EOL><DEDENT>if ((HDF5StorageService.MODIFY_ROW in flags or HDF5StorageService.ADD_ROW in flags) and<EOL>HDF5StorageService.REMOVE_ROW in flags):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if row is None and HDF5StorageService.ADD_ROW in flags:<EOL><INDENT>row = table.row<EOL>self._all_insert_into_row(row, insert_dict)<EOL>row.append()<EOL><DEDENT>elif row is not None and HDF5StorageService.MODIFY_ROW in flags:<EOL><INDENT>self._all_insert_into_row(row, insert_dict)<EOL>row.update()<EOL><DEDENT>elif HDF5StorageService.REMOVE_ROW in flags:<EOL><INDENT>if row is not None:<EOL><INDENT>row_number = row.nrow<EOL>try:<EOL><INDENT>table.remove_rows(start=row_number, stop=row_number+<NUM_LIT:1>)<EOL><DEDENT>except NotImplementedError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._all_kill_iterator(row_iterator)<EOL>table.flush()<EOL>if HDF5StorageService.REMOVE_ROW not in flags and row is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>' % (item_name, table._v_name))<EOL><DEDENT>

Adds or changes a row in a pytable.

        :param item_name: Name of item, the row is about, only important for throwing errors.

        :param insert_dict:

            Dictionary of data that is about to be inserted into the pytables row.

        :param table:

            The table to insert or modify a row in

        :param index:

            Index of row to be modified. Instead of an index a search condition can be
            used as well, see below.

        :param condition:

            Condition to search for in the table

        :param condvars:

            Variables for the search condition

        :param flags:

            Flags whether to add, modify, or remove a row in the table


if load_data == pypetconstants.LOAD_NOTHING:<EOL><INDENT>return<EOL><DEDENT>if _hdf5_group is None:<EOL><INDENT>_hdf5_group = self._all_get_node_by_name(instance.v_full_name)<EOL><DEDENT>if load_data == pypetconstants.OVERWRITE_DATA:<EOL><INDENT>if instance.v_is_parameter and instance.v_locked:<EOL><INDENT>self._logger.debug('<STR_LIT>' %<EOL>instance.v_full_name)<EOL>return<EOL><DEDENT>instance.f_empty()<EOL>instance.v_annotations.f_empty()<EOL>instance.v_comment = '<STR_LIT>'<EOL><DEDENT>self._all_load_skeleton(instance, _hdf5_group)<EOL>instance._stored = True<EOL>if isinstance(load_only, str):<EOL><INDENT>load_only = [load_only]<EOL><DEDENT>if isinstance(load_except, str):<EOL><INDENT>load_except = [load_except]<EOL><DEDENT>if load_data == pypetconstants.LOAD_SKELETON:<EOL><INDENT>self._node_processing_timer.signal_update()<EOL>return<EOL><DEDENT>elif load_only is not None:<EOL><INDENT>if load_except is not None:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>elif instance.v_is_parameter and instance.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>instance.v_full_name)<EOL><DEDENT>self._logger.debug('<STR_LIT>' %<EOL>str(load_only))<EOL>load_only = set(load_only)<EOL><DEDENT>elif load_except is not None:<EOL><INDENT>if instance.v_is_parameter and instance.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>instance.v_full_name)<EOL><DEDENT>self._logger.debug('<STR_LIT>' %<EOL>str(load_except))<EOL>load_except = set(load_except)<EOL><DEDENT>elif not instance.f_is_empty():<EOL><INDENT>self._node_processing_timer.signal_update()<EOL>return<EOL><DEDENT>full_name = instance.v_full_name<EOL>self._logger.debug('<STR_LIT>' % full_name)<EOL>load_dict = {}  <EOL>if load_flags is None:<EOL><INDENT>load_flags = {}<EOL><DEDENT>try:<EOL><INDENT>instance_flags = instance._load_flags().copy() <EOL><DEDENT>except AttributeError:<EOL><INDENT>instance_flags = {}<EOL><DEDENT>instance_flags.update(load_flags)<EOL>load_flags = instance_flags<EOL>self._prm_load_into_dict(full_name=full_name,<EOL>load_dict=load_dict,<EOL>hdf5_group=_hdf5_group,<EOL>instance=instance,<EOL>load_only=load_only,<EOL>load_except=load_except,<EOL>load_flags=load_flags)<EOL>if load_only is not None:<EOL><INDENT>if len(load_only) > <NUM_LIT:0>:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(str(load_only), full_name))<EOL><DEDENT><DEDENT>elif load_except is not None:<EOL><INDENT>if len(load_except) > <NUM_LIT:0>:<EOL><INDENT>self._logger.warning(('<STR_LIT>'<EOL>'<STR_LIT>' % (str(load_except), full_name)))<EOL><DEDENT><DEDENT>if load_dict:<EOL><INDENT>try:<EOL><INDENT>instance._load(load_dict)<EOL>if instance.v_is_parameter:<EOL><INDENT>instance.f_lock()<EOL><DEDENT><DEDENT>except:<EOL><INDENT>self._logger.error(<EOL>'<STR_LIT>' % full_name)<EOL>raise<EOL><DEDENT><DEDENT>self._node_processing_timer.signal_update()<EOL>

Loads a parameter or result from disk.

        :param instance:

            Empty parameter or result instance

        :param load_data:

            How to load stuff

        :param load_only:

            List of data keys if only parts of a result should be loaded

        :param load_except:

            List of data key that should NOT be loaded.

        :param load_flags:

            Dictionary to determine how something is loaded

        :param with_links:

            Placeholder, because leaves have no links

        :param recursive:

            Dummy variable, no-op because leaves have no children

        :param max_depth:

            Dummy variable, no-op because leaves have no children

        :param _hdf5_group:

            The corresponding hdf5 group of the instance


def _all_get_or_create_table(self, where, tablename, description, expectedrows=None):

where_node = self._hdf5file.get_node(where)<EOL>if not tablename in where_node:<EOL><INDENT>if not expectedrows is None:<EOL><INDENT>table = self._hdf5file.create_table(where=where_node, name=tablename,<EOL>description=description, title=tablename,<EOL>expectedrows=expectedrows,<EOL>filters=self._all_get_filters())<EOL><DEDENT>else:<EOL><INDENT>table = self._hdf5file.create_table(where=where_node, name=tablename,<EOL>description=description, title=tablename,<EOL>filters=self._all_get_filters())<EOL><DEDENT><DEDENT>else:<EOL><INDENT>table = where_node._f_get_child(tablename)<EOL><DEDENT>return table<EOL>

Creates a new table, or if the table already exists, returns it.


return self._fletcher32<EOL>


def _srvc_load_several_items(self, iterable, *args, **kwargs):

for input_tuple in iterable:<EOL><INDENT>msg = input_tuple[<NUM_LIT:0>]<EOL>item = input_tuple[<NUM_LIT:1>]<EOL>if len(input_tuple) > <NUM_LIT:2>:<EOL><INDENT>args = input_tuple[<NUM_LIT:2>]<EOL><DEDENT>if len(input_tuple) > <NUM_LIT:3>:<EOL><INDENT>kwargs = input_tuple[<NUM_LIT:3>]<EOL><DEDENT>if len(input_tuple) > <NUM_LIT:4>:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>self.load(msg, item, *args, **kwargs)<EOL><DEDENT>

Loads several items from an iterable

        Iterables are supposed to be of a format like `[(msg, item, args, kwarg),...]`
        If `args` and `kwargs` are not part of a tuple, they are taken from the
        current `args` and `kwargs` provided to this function.


def _all_load_skeleton(self, traj_node, hdf5_group):

if traj_node.v_annotations.f_is_empty():<EOL><INDENT>self._ann_load_annotations(traj_node, hdf5_group)<EOL><DEDENT>if traj_node.v_comment == '<STR_LIT>':<EOL><INDENT>comment = self._all_get_from_attrs(hdf5_group, HDF5StorageService.COMMENT)<EOL>if comment is None:<EOL><INDENT>comment = '<STR_LIT>'<EOL><DEDENT>traj_node.v_comment = comment<EOL><DEDENT>


def _tree_create_leaf(self, name, trajectory, hdf5_group):

class_name = self._all_get_from_attrs(hdf5_group, HDF5StorageService.CLASS_NAME)<EOL>class_constructor = trajectory._create_class(class_name)<EOL>instance = trajectory._construct_instance(class_constructor, name)<EOL>return instance<EOL>

Creates a new pypet leaf instance.

        Returns the leaf and if it is an explored parameter the length of the range.


return self._complib<EOL>


path_name = name.replace('<STR_LIT:.>', '<STR_LIT:/>')<EOL>where = '<STR_LIT>' % (self._trajectory_name, path_name)<EOL>return self._hdf5file.get_node(where=where)<EOL>

Returns an HDF5 node by the path specified in `name`


if kwargs is None:<EOL><INDENT>kwargs = {}<EOL><DEDENT>complib = kwargs.pop('<STR_LIT>', None)<EOL>complevel = kwargs.pop('<STR_LIT>', None)<EOL>shuffle = kwargs.pop('<STR_LIT>', None)<EOL>fletcher32 = kwargs.pop('<STR_LIT>', None)<EOL>if complib is not None:<EOL><INDENT>self._filters = None<EOL><DEDENT>else:<EOL><INDENT>complib = self._complib<EOL><DEDENT>if complevel is not None:<EOL><INDENT>self._filters = None<EOL><DEDENT>else:<EOL><INDENT>complevel = self._complevel<EOL><DEDENT>if shuffle is not None:<EOL><INDENT>self._filters = None<EOL><DEDENT>else:<EOL><INDENT>shuffle = self._shuffle<EOL><DEDENT>if fletcher32 is not None:<EOL><INDENT>self._filters = None<EOL><DEDENT>else:<EOL><INDENT>fletcher32 = self._fletcher32<EOL><DEDENT>if self._filters is None:<EOL><INDENT>self._filters = pt.Filters(complib=complib, complevel=complevel,<EOL>shuffle=shuffle, fletcher32=fletcher32)<EOL>self._hdf5file.filters = self._filters<EOL>self._hdf5store._filters = self._filters<EOL>self._hdf5store._complevel = complevel<EOL>self._hdf5store._complib = complib<EOL>self._hdf5store._fletcher32 = fletcher32<EOL><DEDENT>return self._filters<EOL>

Makes filters

        Pops filter arguments from `kwargs` such that they are not passed
        on to other functions also using kwargs.


def _tree_load_link(self, new_traj_node, load_data, traj, as_new, hdf5_soft_link):

try:<EOL><INDENT>linked_group = hdf5_soft_link()<EOL>link_name = hdf5_soft_link._v_name<EOL>if (not link_name in new_traj_node._links or<EOL>load_data==pypetconstants.OVERWRITE_DATA):<EOL><INDENT>link_location = linked_group._v_pathname<EOL>full_name = '<STR_LIT:.>'.join(link_location.split('<STR_LIT:/>')[<NUM_LIT:2>:])<EOL>if not full_name in traj:<EOL><INDENT>self._tree_load_sub_branch(traj, full_name,<EOL>load_data=pypetconstants.LOAD_SKELETON,<EOL>with_links=False, recursive=False, _trajectory=traj,<EOL>_as_new=as_new, _hdf5_group=self._trajectory_group)<EOL><DEDENT>if (load_data == pypetconstants.OVERWRITE_DATA and<EOL>link_name in new_traj_node._links):<EOL><INDENT>new_traj_node.f_remove_link(link_name)<EOL><DEDENT>if not link_name in new_traj_node._links:<EOL><INDENT>new_traj_node._nn_interface._add_generic(new_traj_node,<EOL>type_name=nn.LINK,<EOL>group_type_name=nn.GROUP,<EOL>args=(link_name,<EOL>traj.f_get(full_name)),<EOL>kwargs={},<EOL>add_prefix=False,<EOL>check_naming=False)<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(hdf5_soft_link._v_name, new_traj_node.v_full_name))<EOL><DEDENT>

Loads a link

        :param new_traj_node: Node in traj containing link
        :param load_data: How to load data in the linked node
        :param traj: The trajectory
        :param as_new: If data in linked node should be loaded as new
        :param hdf5_soft_link: The hdf5 soft link


def _trj_load_trajectory(self, traj, as_new, load_parameters, load_derived_parameters,<EOL>load_results, load_other_data, recursive, max_depth,<EOL>with_run_information, with_meta_data, force):

<EOL>if (as_new and (load_derived_parameters != pypetconstants.LOAD_NOTHING or<EOL>load_results != pypetconstants.LOAD_NOTHING or<EOL>load_other_data != pypetconstants.LOAD_NOTHING)):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if as_new and load_parameters != pypetconstants.LOAD_DATA:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>loadconstants = (pypetconstants.LOAD_NOTHING, pypetconstants.LOAD_SKELETON,<EOL>pypetconstants.LOAD_DATA, pypetconstants.OVERWRITE_DATA)<EOL>if not (load_parameters in loadconstants and load_derived_parameters in loadconstants and<EOL>load_results in loadconstants and load_other_data in loadconstants):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % str(loadconstants))<EOL><DEDENT>traj._stored = not as_new<EOL>load_data = max(load_parameters, load_derived_parameters, load_results, load_other_data)<EOL>if with_meta_data:<EOL><INDENT>self._trj_load_meta_data(traj, load_data, as_new, with_run_information, force)<EOL><DEDENT>if (load_parameters != pypetconstants.LOAD_NOTHING or<EOL>load_derived_parameters != pypetconstants.LOAD_NOTHING or<EOL>load_results != pypetconstants.LOAD_NOTHING or<EOL>load_other_data != pypetconstants.LOAD_NOTHING):<EOL><INDENT>self._logger.info('<STR_LIT>' % traj.v_name)<EOL><DEDENT>else:<EOL><INDENT>self._logger.info('<STR_LIT>' % traj.v_name)<EOL>return<EOL><DEDENT>maximum_display_other = <NUM_LIT:10><EOL>counter = <NUM_LIT:0><EOL>for children in [self._trajectory_group._v_groups, self._trajectory_group._v_links]:<EOL><INDENT>for hdf5_group_name in children:<EOL><INDENT>hdf5_group = children[hdf5_group_name]<EOL>child_name = hdf5_group._v_name<EOL>load_subbranch = True<EOL>if child_name == '<STR_LIT>':<EOL><INDENT>if as_new:<EOL><INDENT>loading = pypetconstants.LOAD_NOTHING<EOL><DEDENT>else:<EOL><INDENT>loading = load_parameters<EOL><DEDENT><DEDENT>elif child_name == '<STR_LIT>':<EOL><INDENT>loading = load_parameters<EOL><DEDENT>elif child_name == '<STR_LIT>':<EOL><INDENT>loading = load_results<EOL><DEDENT>elif child_name == '<STR_LIT>':<EOL><INDENT>loading = load_derived_parameters<EOL><DEDENT>elif child_name == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>loading = load_other_data<EOL>load_subbranch = False<EOL><DEDENT>if loading == pypetconstants.LOAD_NOTHING:<EOL><INDENT>continue<EOL><DEDENT>if load_subbranch:<EOL><INDENT>self._logger.info('<STR_LIT>' %<EOL>(child_name, str(loading)))<EOL><DEDENT>else:<EOL><INDENT>if counter < maximum_display_other:<EOL><INDENT>self._logger.info(<EOL>'<STR_LIT>' % (child_name, str(loading)))<EOL><DEDENT>elif counter == maximum_display_other:<EOL><INDENT>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>counter += <NUM_LIT:1><EOL><DEDENT>self._tree_load_sub_branch(traj, child_name, load_data=loading, with_links=True,<EOL>recursive=recursive,<EOL>max_depth=max_depth,<EOL>_trajectory=traj, _as_new=as_new,<EOL>_hdf5_group=self._trajectory_group)<EOL><DEDENT><DEDENT>

Loads a single trajectory from a given file.

        :param traj: The trajectory

        :param as_new: Whether to load trajectory as new

        :param load_parameters: How to load parameters and config

        :param load_derived_parameters: How to load derived parameters

        :param load_results: How to load results

        :param load_other_data: How to load anything not within the four subbranches

        :param recursive: If data should be loaded recursively

        :param max_depth: Maximum depth of loading

        :param with_run_information:

            If run information should be loaded

        :param with_meta_data:

            If meta data infor should be loaded

        :param force: Force load in case there is a pypet version mismatch

        You can specify how to load the parameters, derived parameters and results
        as follows:

        :const:`pypet.pypetconstants.LOAD_NOTHING`: (0)

            Nothing is loaded

        :const:`pypet.pypetconstants.LOAD_SKELETON`: (1)

            The skeleton including annotations are loaded, i.e. the items are empty.
            Non-empty items in RAM are left untouched.

        :const:`pypet.pypetconstants.LOAD_DATA`: (2)

            The whole data is loaded.
            Only empty or in RAM non-existing instance are filled with the
            data found on disk.

        :const:`pypet.pypetconstants.OVERWRITE_DATA`: (3)

            The whole data is loaded.
            If items that are to be loaded are already in RAM and not empty,
            they are emptied and new data is loaded from disk.

        If `as_new=True` the old trajectory is loaded into the new one, only parameters can be
        loaded. If `as_new=False` the current trajectory is completely replaced by the one
        on disk, i.e. the name from disk, the timestamp, etc. are assigned to `traj`.


def _srvc_make_overview_tables(self, tables_to_make, traj=None):

for table_name in tables_to_make:<EOL><INDENT>paramdescriptiondict = {}<EOL>expectedrows = <NUM_LIT:0><EOL>paramdescriptiondict['<STR_LIT:location>'] = pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_LOCATION_LENGTH,<EOL>pos=<NUM_LIT:0>)<EOL>paramdescriptiondict['<STR_LIT:name>'] = pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH,<EOL>pos=<NUM_LIT:1>)<EOL>paramdescriptiondict['<STR_LIT>'] = pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_COMMENT_LENGTH)<EOL>paramdescriptiondict['<STR_LIT:value>'] = pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_VALUE_LENGTH, pos=<NUM_LIT:2>)<EOL>if table_name == '<STR_LIT>':<EOL><INDENT>if traj is not None:<EOL><INDENT>expectedrows = len(traj._config)<EOL><DEDENT><DEDENT>if table_name == '<STR_LIT>':<EOL><INDENT>if traj is not None:<EOL><INDENT>expectedrows = len(traj._parameters)<EOL><DEDENT><DEDENT>if table_name == '<STR_LIT>':<EOL><INDENT>paramdescriptiondict['<STR_LIT>'] = pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_RANGE_LENGTH)<EOL>paramdescriptiondict['<STR_LIT>'] = pt.IntCol()<EOL>if traj is not None:<EOL><INDENT>expectedrows = len(traj._explored_parameters)<EOL><DEDENT><DEDENT>if table_name.endswith('<STR_LIT>'):<EOL><INDENT>paramdescriptiondict['<STR_LIT>'] = pt.StringCol(<NUM_LIT:64>, pos=<NUM_LIT:10>)<EOL><DEDENT>if table_name == '<STR_LIT>':<EOL><INDENT>expectedrows = self._derived_parameters_per_run<EOL>if traj is not None:<EOL><INDENT>expectedrows *= len(traj)<EOL>expectedrows += len(traj._derived_parameters)<EOL><DEDENT><DEDENT>if table_name == '<STR_LIT>':<EOL><INDENT>expectedrows = self._results_per_run<EOL>if traj is not None:<EOL><INDENT>expectedrows *= len(traj)<EOL>expectedrows += len(traj._results)<EOL><DEDENT><DEDENT>if expectedrows > <NUM_LIT:0>:<EOL><INDENT>paramtable = self._all_get_or_create_table(where=self._overview_group,<EOL>tablename=table_name,<EOL>description=paramdescriptiondict,<EOL>expectedrows=expectedrows)<EOL><DEDENT>else:<EOL><INDENT>paramtable = self._all_get_or_create_table(where=self._overview_group,<EOL>tablename=table_name,<EOL>description=paramdescriptiondict)<EOL><DEDENT>paramtable.flush()<EOL><DEDENT>

Creates the overview tables in overview group


def _grp_store_group(self, traj_group, store_data=pypetconstants.STORE_DATA,<EOL>with_links=True, recursive=False, max_depth=None,<EOL>_hdf5_group=None, _newly_created=False):

if store_data == pypetconstants.STORE_NOTHING:<EOL><INDENT>return<EOL><DEDENT>elif store_data == pypetconstants.STORE_DATA_SKIPPING and traj_group._stored:<EOL><INDENT>self._logger.debug('<STR_LIT>' %<EOL>traj_group.v_full_name)<EOL><DEDENT>elif not recursive:<EOL><INDENT>if _hdf5_group is None:<EOL><INDENT>_hdf5_group, _newly_created = self._all_create_or_get_groups(traj_group.v_full_name)<EOL><DEDENT>overwrite = store_data == pypetconstants.OVERWRITE_DATA<EOL>if (traj_group.v_comment != '<STR_LIT>' and<EOL>(HDF5StorageService.COMMENT not in _hdf5_group._v_attrs or overwrite)):<EOL><INDENT>setattr(_hdf5_group._v_attrs, HDF5StorageService.COMMENT, traj_group.v_comment)<EOL><DEDENT>if ((_newly_created or overwrite) and<EOL>type(traj_group) not in (nn.NNGroupNode, nn.ConfigGroup, nn.ParameterGroup,<EOL>nn.DerivedParameterGroup, nn.ResultGroup)):<EOL><INDENT>setattr(_hdf5_group._v_attrs, HDF5StorageService.CLASS_NAME,<EOL>traj_group.f_get_class_name())<EOL><DEDENT>self._ann_store_annotations(traj_group, _hdf5_group, overwrite=overwrite)<EOL>self._hdf5file.flush()<EOL>traj_group._stored = True<EOL>self._node_processing_timer.signal_update()<EOL><DEDENT>if recursive:<EOL><INDENT>parent_traj_group = traj_group.f_get_parent()<EOL>parent_hdf5_group = self._all_create_or_get_groups(parent_traj_group.v_full_name)[<NUM_LIT:0>]<EOL>self._tree_store_nodes_dfs(parent_traj_group, traj_group.v_name, store_data=store_data,<EOL>with_links=with_links, recursive=recursive,<EOL>max_depth=max_depth, current_depth=<NUM_LIT:0>,<EOL>parent_hdf5_group=parent_hdf5_group)<EOL><DEDENT>

Stores a group node.

        For group nodes only annotations and comments need to be stored.


def _trj_check_version(self, version, python, force):

curr_python = pypetconstants.python_version_string<EOL>if (version != VERSION or curr_python != python) and not force:<EOL><INDENT>raise pex.VersionMismatchError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(VERSION, curr_python, version, python))<EOL><DEDENT>elif version != VERSION or curr_python != python:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(VERSION, curr_python, version, python))<EOL><DEDENT>

Checks for version mismatch

        Raises a VersionMismatchError if version of loaded trajectory and current pypet version
        do not match. In case of `force=True` error is not raised only a warning is emitted.


for attr_name in HDF5StorageService.ATTR_LIST:<EOL><INDENT>try:<EOL><INDENT>config = traj.f_get('<STR_LIT>' + attr_name).f_get()<EOL>setattr(self, attr_name, config)<EOL><DEDENT>except AttributeError:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(attr_name, str(getattr(self, attr_name))))<EOL><DEDENT><DEDENT>for attr_name, table_name in HDF5StorageService.NAME_TABLE_MAPPING.items():<EOL><INDENT>try:<EOL><INDENT>if table_name in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>table_name += '<STR_LIT>'<EOL><DEDENT>config = traj.f_get('<STR_LIT>' + table_name).f_get()<EOL>setattr(self, attr_name, config)<EOL><DEDENT>except AttributeError:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(table_name, str(getattr(self, attr_name))))<EOL><DEDENT><DEDENT>for attr_name, name in HDF5StorageService.PR_ATTR_NAME_MAPPING.items():<EOL><INDENT>try:<EOL><INDENT>config = traj.f_get('<STR_LIT>' + name).f_get()<EOL>setattr(self, attr_name, config)<EOL><DEDENT>except AttributeError:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(name, str(getattr(self, attr_name))))<EOL><DEDENT><DEDENT>if ((not self._overview_results_summary or<EOL>not self._overview_derived_parameters_summary) and<EOL>self._purge_duplicate_comments):<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._filters = None<EOL>

Reads out the properties for storing new data into the hdf5file

        :param traj:

            The trajectory


def _prm_read_array(self, array, full_name):

try:<EOL><INDENT>result = self._svrc_read_array(array)<EOL>result, dummy = self._all_recall_native_type(result, array,<EOL>HDF5StorageService.DATA_PREFIX)<EOL>return result<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>' % (array._v_name, full_name))<EOL>raise<EOL><DEDENT>

Reads data from an array or carray

        :param array:

            PyTables array or carray to read from

        :param full_name:

            Full name of the parameter or result whose data is to be loaded

        :return:

            Data to load


if not self._storage_service.is_open:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>category=RuntimeWarning)<EOL><DEDENT>return self._request_data('<STR_LIT>')<EOL>

Returns the actula node of the underlying data.

        In case one uses HDF5 this will be the HDF5 leaf node.


service = self._traj.v_storage_service<EOL>if service.is_open:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>service.store(pypetconstants.OPEN_FILE, None,<EOL>trajectory_name=self._traj.v_name)<EOL>

Opens store manually not needed if used with `with`


if '<STR_LIT>' not in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = self.FLAG<EOL><DEDENT>if '<STR_LIT:data>' in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = kwargs.pop('<STR_LIT:data>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self.traj = kwargs.pop('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self.traj = kwargs.pop('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:name>' in kwargs:<EOL><INDENT>self.name = kwargs.pop['<STR_LIT:name>']<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self.parent = kwargs.pop('<STR_LIT>')<EOL>if self.name is not None:<EOL><INDENT>self.parent[self.name] = self<EOL><DEDENT><DEDENT>return self._request_data('<STR_LIT>', kwargs=kwargs)<EOL>

Creates shared data on disk with a StorageService on disk.

        Needs to be called before shared data can be used later on.

        Actual arguments of ``kwargs`` depend on the type of data to be
        created. For instance, creating an array one can use the keyword
        ``obj`` to pass a numpy array (``obj=np.zeros((10,20,30))``).
        Whereas for a PyTables table may need a description dictionary
        (``description={'column_1': pt.StringCol(2, pos=0),'column_2': pt.FloatCol( pos=1)}``)
        Refer to the PyTables documentation on how to create tables.


service = self._traj.v_storage_service<EOL>if not service.is_open:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>service.store(pypetconstants.CLOSE_FILE, None)<EOL>

Closes store manually not needed if used with `with`


def create_shared_data(self, name=None, **kwargs):

if name is None:<EOL><INDENT>item = self.f_get()<EOL><DEDENT>else:<EOL><INDENT>item = self.f_get(name)<EOL><DEDENT>return item.create_shared_data(**kwargs)<EOL>

Calls the corresponding function of the shared data item


return self._storage_service.is_open<EOL>

Normally the file is opened and closed after each insertion.

        However, the storage service may provide the option to keep the store open and signals
        this via this property.


raise NotImplementedError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>


if self._context is not None:<EOL><INDENT>if self._socket is not None:<EOL><INDENT>self._close_socket(confused=False)<EOL><DEDENT>self._context.term()<EOL>self._context = None<EOL>self._poll = None<EOL><DEDENT>

Closes socket and terminates context

        NO-OP if already closed.


def store(self, msg, stuff_to_store, *args, **kwargs):

trajectory_name = kwargs['<STR_LIT>']<EOL>if trajectory_name not in self.references:<EOL><INDENT>self.references[trajectory_name] = []<EOL><DEDENT>self.references[trajectory_name].append((msg, cp.copy(stuff_to_store), args, kwargs))<EOL>

Simply keeps a reference to the stored data


try:<EOL><INDENT>self.acquire_lock()<EOL>return self._storage_service.load(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>if self.lock is not None:<EOL><INDENT>try:<EOL><INDENT>self.release_lock()<EOL><DEDENT>except RuntimeError:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(self.lock))<EOL><DEDENT><DEDENT><DEDENT>

Acquires a lock before loading and releases it afterwards.


@retry(<NUM_LIT:9>, Exception, <NUM_LIT>, '<STR_LIT>')<EOL><INDENT>def _put_on_pipe(self, to_put):<DEDENT>

self.acquire_lock()<EOL>self._send_chunks(to_put)<EOL>self.release_lock()<EOL>


return True<EOL>

This wrapper guarantees multiprocessing safety


return True<EOL>

Usually storage services are not supposed to be multiprocessing safe


def _unlock(self, name, client_id, request_id):

if name in self._locks:<EOL><INDENT>other_client_id, other_request_id, lock_time = self._locks[name]<EOL>if other_client_id != client_id:<EOL><INDENT>response = (self.RELEASE_ERROR + self.DELIMITER +<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (name,<EOL>other_client_id,<EOL>other_request_id,<EOL>client_id,<EOL>request_id))<EOL>self._logger.error(response)<EOL>return response<EOL><DEDENT>else:<EOL><INDENT>del self._locks[name]<EOL>return self.RELEASED<EOL><DEDENT><DEDENT>elif (name, client_id) in self._timeout_locks:<EOL><INDENT>other_request_id, lock_time = self._timeout_locks[(name, client_id)]<EOL>timeout = time.time() - lock_time - self._timeout<EOL>response = (self.RELEASE_ERROR + self.DELIMITER +<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (name, timeout, client_id, other_request_id))<EOL>return response<EOL><DEDENT>else:<EOL><INDENT>response = (self.RELEASE_ERROR + self.DELIMITER +<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (name, client_id, request_id))<EOL>self._logger.warning(response)<EOL>return response<EOL><DEDENT>


def __call__(self, index, total, percentage_step=<NUM_LIT:5>, logger='<STR_LIT>', log_level=logging.INFO,<EOL>reprint=False, time=True, length=<NUM_LIT:20>, fmt_string=None,  reset=False):

reset = (reset or<EOL>index <= self._current_index or<EOL>total != self._total)<EOL>if reset:<EOL><INDENT>self._reset(index, total, percentage_step, length)<EOL><DEDENT>statement = None<EOL>indexp1 = index + <NUM_LIT:1.0><EOL>next_interval = int(indexp1 / self._norm_factor)<EOL>ending = index >= self._total_minus_one<EOL>if next_interval > self._current_interval or ending or reset:<EOL><INDENT>if time:<EOL><INDENT>remaining_str = self._get_remaining(index)<EOL><DEDENT>else:<EOL><INDENT>remaining_str = '<STR_LIT>'<EOL><DEDENT>if ending:<EOL><INDENT>statement = '<STR_LIT:[>' + '<STR_LIT:=>' * self._length +'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>bars = int((indexp1 / self._total) * self._length)<EOL>spaces = self._length - bars<EOL>percentage = indexp1 / self._total * <NUM_LIT><EOL>if reset:<EOL><INDENT>statement = ('<STR_LIT:[>' + '<STR_LIT:=>' * bars +<EOL>'<STR_LIT:U+0020>' * spaces + '<STR_LIT:]>' + '<STR_LIT>' % percentage + '<STR_LIT:%>')<EOL><DEDENT>else:<EOL><INDENT>statement = ('<STR_LIT:[>' + '<STR_LIT:=>' * bars +<EOL>'<STR_LIT:U+0020>' * spaces + '<STR_LIT:]>' + '<STR_LIT>' % percentage + '<STR_LIT:%>' +<EOL>remaining_str)<EOL><DEDENT><DEDENT>if fmt_string:<EOL><INDENT>statement = fmt_string % statement<EOL><DEDENT>if logger == '<STR_LIT>':<EOL><INDENT>if reprint:<EOL><INDENT>print('<STR_LIT:\r>' + statement, end='<STR_LIT>', flush=True)<EOL><DEDENT>else:<EOL><INDENT>print(statement)<EOL><DEDENT><DEDENT>elif logger is not None:<EOL><INDENT>if isinstance(logger, str):<EOL><INDENT>logger = logging.getLogger(logger)<EOL><DEDENT>logger.log(msg=statement, level=log_level)<EOL><DEDENT><DEDENT>self._current_interval = next_interval<EOL>self._current_index = index<EOL>return statement<EOL>

Plots a progress bar to the given `logger` for large for loops.

        To be used inside a for-loop at the end of the loop.

        :param index: Current index of for-loop
        :param total: Total size of for-loop
        :param percentage_step: Percentage step with which the bar should be updated
        :param logger:

            Logger to write to, if string 'print' is given, the print statement is
            used. Use None if you don't want to print or log the progressbar statement.

        :param log_level: Log level with which to log.
        :param reprint:

            If no new line should be plotted but carriage return (works only for printing)

        :param time: If the remaining time should be calculated and displayed
        :param length: Length of the bar in `=` signs.
        :param fmt_string:

            A string which contains exactly one `%s` in order to incorporate the progressbar.
            If such a string is given, ``fmt_string % progressbar`` is printed/logged.

        :param reset:

            If the progressbar should be restarted. If progressbar is called with a lower
            index than the one before, the progressbar is automatically restarted.

        :return:

            The progressbar string or None if the string has not been updated.


def progressbar(index, total, percentage_step=<NUM_LIT:10>, logger='<STR_LIT>', log_level=logging.INFO,<EOL>reprint=True, time=True, length=<NUM_LIT:20>, fmt_string=None, reset=False):

return _progressbar(index=index, total=total, percentage_step=percentage_step,<EOL>logger=logger, log_level=log_level, reprint=reprint,<EOL>time=time, length=length, fmt_string=fmt_string, reset=reset)<EOL>

Plots a progress bar to the given `logger` for large for loops.

    To be used inside a for-loop at the end of the loop:

    .. code-block:: python

        for irun in range(42):
            my_costly_job() # Your expensive function
            progressbar(index=irun, total=42, reprint=True) # shows a growing progressbar

    There is no initialisation of the progressbar necessary before the for-loop.
    The progressbar will be reset automatically if used in another for-loop.

    :param index: Current index of for-loop
    :param total: Total size of for-loop
    :param percentage_step: Steps with which the bar should be plotted
    :param logger:

        Logger to write to - with level INFO. If string 'print' is given, the print statement is
        used. Use ``None`` if you don't want to print or log the progressbar statement.

    :param log_level: Log level with which to log.
    :param reprint:

        If no new line should be plotted but carriage return (works only for printing)

    :param time: If the remaining time should be estimated and displayed
    :param length: Length of the bar in `=` signs.
    :param fmt_string:

        A string which contains exactly one `%s` in order to incorporate the progressbar.
        If such a string is given, ``fmt_string % progressbar`` is printed/logged.

    :param reset:

        If the progressbar should be restarted. If progressbar is called with a lower
        index than the one before, the progressbar is automatically restarted.

    :return:

        The progressbar string or `None` if the string has not been updated.


if inspect.isclass(func):<EOL><INDENT>func = func.__init__<EOL><DEDENT>if not inspect.isfunction(func):<EOL><INDENT>return [], False<EOL><DEDENT>parameters = inspect.signature(func).parameters<EOL>args = []<EOL>uses_starstar = False<EOL>for par in parameters.values():<EOL><INDENT>if (par.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD or<EOL>par.kind == inspect.Parameter.KEYWORD_ONLY):<EOL><INDENT>args.append(par.name)<EOL><DEDENT>elif par.kind == inspect.Parameter.VAR_KEYWORD:<EOL><INDENT>uses_starstar = True<EOL><DEDENT><DEDENT>return args, uses_starstar<EOL>

Helper function to support both Python versions


<EOL>domain_name = socket.getfqdn()<EOL>try:<EOL><INDENT>addr_list = socket.getaddrinfo(domain_name, None)<EOL><DEDENT>except Exception:<EOL><INDENT>addr_list = socket.getaddrinfo('<STR_LIT:127.0.0.1>', None)<EOL><DEDENT>family, socktype, proto, canonname, sockaddr = addr_list[<NUM_LIT:0>]<EOL>host = convert_ipv6(sockaddr[<NUM_LIT:0>])<EOL>address =  '<STR_LIT>' + host<EOL>if port is None:<EOL><INDENT>port = ()<EOL><DEDENT>if not isinstance(port, int):<EOL><INDENT>context = zmq.Context()<EOL>try:<EOL><INDENT>socket_ = context.socket(zmq.REP)<EOL>socket_.ipv6 = is_ipv6(address)<EOL>port = socket_.bind_to_random_port(address, *port)<EOL><DEDENT>except Exception:<EOL><INDENT>print('<STR_LIT>'.format(address, addr_list))<EOL>pypet_root_logger = logging.getLogger('<STR_LIT>')<EOL>pypet_root_logger.exception('<STR_LIT>'.format(address))<EOL>raise<EOL><DEDENT>socket_.close()<EOL>context.term()<EOL><DEDENT>return address + '<STR_LIT::>' + str(port)<EOL>

Returns local tcp address for a given `port`, automatic port if `None`


in_dir = os.listdir(folder)<EOL>all_files = []<EOL>for file in in_dir:<EOL><INDENT>full_file = os.path.join(folder, file)<EOL>if os.path.isfile(full_file):<EOL><INDENT>_, extension = os.path.splitext(full_file)<EOL>if extension == ext:<EOL><INDENT>all_files.append(full_file)<EOL><DEDENT><DEDENT><DEDENT>all_files = sorted(all_files)<EOL>trajs = []<EOL>for full_file in all_files:<EOL><INDENT>traj = load_trajectory(index=-<NUM_LIT:1>,<EOL>storage_service=storage_service,<EOL>filename=full_file,<EOL>load_data=<NUM_LIT:0>,<EOL>force=force,<EOL>dynamic_imports=dynamic_imports)<EOL>trajs.append(traj)<EOL><DEDENT>first_traj = trajs.pop(<NUM_LIT:0>)<EOL>first_traj.f_merge_many(trajs,<EOL>ignore_data=ignore_data,<EOL>move_data=move_data,<EOL>delete_other_trajectory=False,<EOL>keep_info=keep_info,<EOL>keep_other_trajectory_info=keep_other_trajectory_info,<EOL>merge_config=merge_config,<EOL>backup=backup)<EOL>if delete_other_files:<EOL><INDENT>for file in all_files[<NUM_LIT:1>:]:<EOL><INDENT>os.remove(file)<EOL><DEDENT><DEDENT>return first_traj<EOL>

Merges all files in a given folder.

    IMPORTANT: Does not check if there are more than 1 trajectory in a file. Always
    uses the last trajectory in file and ignores the other ones.

    Trajectories are merged according to the alphabetical order of the files,
    i.e. the resulting merged trajectory is found in the first file
    (according to lexicographic ordering).

    :param folder: folder (not recursive) where to look for files
    :param ext: only files with the given extension are used
    :param dynamic_imports: Dynamic imports for loading
    :param storage_service: storage service to use, leave `None` to use the default one
    :param force: If loading should be forced.
    :param delete_other_files: Deletes files of merged trajectories

    All other parameters as in `f_merge_many` of the trajectory.

    :return: The merged traj


while True:<EOL><INDENT>try:<EOL><INDENT>return next(self._current)<EOL><DEDENT>except StopIteration:<EOL><INDENT>try:<EOL><INDENT>self._current = iter(self._chain.popleft())<EOL><DEDENT>except IndexError:<EOL><INDENT>raise StopIteration('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>

Returns next element from chain.

        More precisely, it returns the next element of the
        foremost iterator. If this iterator is empty it moves iteratively
        along the chain of available iterators to pick the new foremost one.

        Raises StopIteration if there are no elements left.


self._ndarray = ndarray<EOL>

Creates a new hashable object encapsulating an ndarray.

            :param ndarray: The wrapped ndarray.


if a is b:<EOL><INDENT>return True<EOL><DEDENT>if a is None or b is None:<EOL><INDENT>return False<EOL><DEDENT>a_sparse = spsp.isspmatrix(a)<EOL>b_sparse = spsp.isspmatrix(b)<EOL>if a_sparse != b_sparse:<EOL><INDENT>return False<EOL><DEDENT>if a_sparse:<EOL><INDENT>if a.nnz == <NUM_LIT:0>:<EOL><INDENT>return b.nnz == <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>return not np.any((a != b).data)<EOL><DEDENT><DEDENT>a_series = isinstance(a, pd.Series)<EOL>b_series = isinstance(b, pd.Series)<EOL>if a_series != b_series:<EOL><INDENT>return False<EOL><DEDENT>if a_series:<EOL><INDENT>try:<EOL><INDENT>eq = (a == b).all()<EOL>return eq<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>if not len(a) == len(b):<EOL><INDENT>return False<EOL><DEDENT>for idx, itema in enumerate(a):<EOL><INDENT>itemb = b[idx]<EOL>if not nested_equal(itema, itemb):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT><DEDENT>a_frame = isinstance(a, pd.DataFrame)<EOL>b_frame = isinstance(b, pd.DataFrame)<EOL>if a_frame != b_frame:<EOL><INDENT>return False<EOL><DEDENT>if a_frame:<EOL><INDENT>try:<EOL><INDENT>if a.empty and b.empty:<EOL><INDENT>return True<EOL><DEDENT>new_frame = a == b<EOL>new_frame = new_frame | (pd.isnull(a) & pd.isnull(b))<EOL>if isinstance(new_frame, pd.DataFrame):<EOL><INDENT>return np.all(new_frame.as_matrix())<EOL><DEDENT><DEDENT>except (ValueError, TypeError):<EOL><INDENT>for name in a:<EOL><INDENT>cola = a[name]<EOL>if not name in b:<EOL><INDENT>return False<EOL><DEDENT>colb = b[name]<EOL>if not len(cola) == len(colb):<EOL><INDENT>return False<EOL><DEDENT>for idx, itema in enumerate(cola):<EOL><INDENT>itemb = colb[idx]<EOL>if not nested_equal(itema, itemb):<EOL><INDENT>return False<EOL><DEDENT><DEDENT><DEDENT>return True<EOL><DEDENT><DEDENT>a_array = isinstance(a, np.ndarray)<EOL>b_array = isinstance(b, np.ndarray)<EOL>if a_array != b_array:<EOL><INDENT>return False<EOL><DEDENT>if a_array:<EOL><INDENT>if a.shape != b.shape:<EOL><INDENT>return False<EOL><DEDENT>return np.all(a == b)<EOL><DEDENT>a_list = isinstance(a, (Sequence, list, tuple))<EOL>b_list = isinstance(b, (Sequence, list, tuple))<EOL>if a_list != b_list:<EOL><INDENT>return False<EOL><DEDENT>if a_list:<EOL><INDENT>return all(nested_equal(x, y) for x, y in zip(a, b))<EOL><DEDENT>a_mapping = isinstance(a, (Mapping, dict))<EOL>b_mapping = isinstance(b, (Mapping, dict))<EOL>if a_mapping != b_mapping:<EOL><INDENT>return False<EOL><DEDENT>if a_mapping:<EOL><INDENT>keys_a = a.keys()<EOL>if set(keys_a) != set(b.keys()):<EOL><INDENT>return False<EOL><DEDENT>return all(nested_equal(a[k], b[k]) for k in keys_a)<EOL><DEDENT>equality = NotImplemented<EOL>try:<EOL><INDENT>equality = a.__eq__(b)<EOL><DEDENT>except (AttributeError, NotImplementedError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT>if equality is NotImplemented:<EOL><INDENT>try:<EOL><INDENT>equality = b.__eq__(a)<EOL><DEDENT>except (AttributeError, NotImplementedError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if equality is NotImplemented:<EOL><INDENT>try:<EOL><INDENT>cmp = a.__cmp__(b)<EOL>if cmp is not NotImplemented:<EOL><INDENT>equality = cmp == <NUM_LIT:0><EOL><DEDENT><DEDENT>except (AttributeError, NotImplementedError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if equality is NotImplemented:<EOL><INDENT>try:<EOL><INDENT>cmp = b.__cmp__(a)<EOL>if cmp is not NotImplemented:<EOL><INDENT>equality = cmp == <NUM_LIT:0><EOL><DEDENT><DEDENT>except (AttributeError, NotImplementedError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if equality is not NotImplemented:<EOL><INDENT>try:<EOL><INDENT>return bool(equality)<EOL><DEDENT>except (AttributeError, NotImplementedError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>attributes_a = get_all_attributes(a)<EOL>attributes_b = get_all_attributes(b)<EOL>if len(attributes_a) != len(attributes_b):<EOL><INDENT>return False<EOL><DEDENT>if len(attributes_a) > <NUM_LIT:0>:<EOL><INDENT>keys_a = list(attributes_a.keys())<EOL>if set(keys_a) != set(attributes_b.keys()):<EOL><INDENT>return False<EOL><DEDENT>return all(nested_equal(attributes_a[k], attributes_b[k]) for k in keys_a)<EOL><DEDENT>return False<EOL>

Compares two objects recursively by their elements.

    Also handles numpy arrays, pandas data and sparse matrices.

    First checks if the data falls into the above categories.
    If not, it is checked if a or b are some type of sequence or mapping and
    the contained elements are compared.
    If this is not the case, it is checked if a or b do provide a custom `__eq__` that
    evaluates to a single boolean value.
    If this is not the case, the attributes of a and b are compared.
    If this does not help either, normal `==` is used.

    Assumes hashable items are not mutable in a way that affects equality.
    Based on the suggestion from HERE_, thanks again Lauritz V. Thaulow :-)

    .. _HERE: http://stackoverflow.com/questions/18376935/best-practice-for-equality-in-python


kwargs = {}<EOL>try:<EOL><INDENT>if self.parser.has_section(section):<EOL><INDENT>options = self.parser.options(section)<EOL>for option in options:<EOL><INDENT>str_val = self.parser.get(section, option)<EOL>val = ast.literal_eval(str_val)<EOL>kwargs[option] = val<EOL><DEDENT><DEDENT>return kwargs<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>


class_data = full_class_string.split("<STR_LIT:.>")<EOL>module_path = "<STR_LIT:.>".join(class_data[:-<NUM_LIT:1>])<EOL>class_str = class_data[-<NUM_LIT:1>]<EOL>module = importlib.import_module(module_path)<EOL>return getattr(module, class_str)<EOL>

Loads a class from a string naming the module and class name.

    For example:
    >>> load_class(full_class_string = 'pypet.brian.parameter.BrianParameter')
    <BrianParameter>


if item.startswith('<STR_LIT>') or item.startswith('<STR_LIT>'):<EOL><INDENT>return getattr(obj, item[<NUM_LIT:2>:])<EOL><DEDENT>raise AttributeError('<STR_LIT>' % (obj.__class__.__name__, item))<EOL>


if item.startswith('<STR_LIT>'):<EOL><INDENT>return setattr(obj, item[<NUM_LIT:2>:], value)<EOL><DEDENT>else:<EOL><INDENT>return super(obj.__class__, obj).__setattr__(item, value)<EOL><DEDENT>


def wrapper(func):<EOL><INDENT>@functools.wraps(func)<EOL>def new_func(*args, **kwargs):<EOL><INDENT>warning_string = "<STR_LIT>" % func.__name__<EOL>warning_string = warning_string + '<STR_LIT:U+0020>' + msg<EOL>warnings.warn(<EOL>warning_string,<EOL>category=DeprecationWarning,<EOL>)<EOL>return func(*args, **kwargs)<EOL><DEDENT>return new_func<EOL><DEDENT>return wrapper<EOL>

This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.

    :param msg:

        Additional message added to the warning.


self._user_pipeline = True<EOL>self._map_arguments = False<EOL>return self._execute_runs(pipeline)<EOL>

You can make *pypet* supervise your whole experiment by defining a pipeline.

        `pipeline` is a function that defines the entire experiment. From pre-processing
        including setting up the trajectory over defining the actual simulation runs to
        post processing.

        The `pipeline` function needs to return TWO tuples with a maximum of three entries each.

        For example:

        ::

            return (runfunc, args, kwargs), (postproc, postproc_args, postproc_kwargs)

        Where `runfunc` is the actual simulation function thet gets passed the trajectory
        container and potentially additional arguments `args` and keyword arguments `kwargs`.
        This will be run by your environment with all parameter combinations.

        `postproc` is a post processing function that handles your computed results.
        The function must accept as arguments the trajectory container, a list of
        results (list of tuples (run idx, result) ) and potentially
        additional arguments `postproc_args` and keyword arguments `postproc_kwargs`.

        As for :func:`~pypet.environment.Environment.f_add_postproc`, this function can
        potentially extend the trajectory.

        If you don't want to apply post-processing, your pipeline function can also simply
        return the run function and the arguments:

        ::

            return runfunc, args, kwargs

        Or

        ::

            return runfunc, args

        Or

        ::

            return runfunc

        ``return runfunc, kwargs`` does NOT work, if you don't want to pass `args` do
        ``return runfunc, (), kwargs``.

        Analogously combinations like

        ::

            return (runfunc, args), (postproc,)

        work as well.

        :param pipeline:

            The pipleine function, taking only a single argument `traj`.
            And returning all functions necessary for your experiment.

        :return:

            List of the individual results returned by `runfunc`.

            Returns a LIST OF TUPLES, where first entry is the run idx and second entry
            is the actual result. In case of multiprocessing these are not necessarily
            ordered according to their run index, but ordered according to their finishing time.

            Does not contain results stored in the trajectory!
            In order to access these simply interact with the trajectory object,
            potentially after calling :func:`~pypet.trajectory.Trajectory.f_update_skeleton`
            and loading all results at once with :func:`~pypet.trajectory.f_load`
            or loading manually with :func:`~pypet.trajectory.f_load_items`.

            Even if you use multiprocessing without a pool the results returned by
            `runfunc` still need to be pickled.

            Results computed from `postproc` are not returned. `postproc` should not
            return any results except dictionaries if the trajectory should be expanded.


for idx, pair in enumerate(self._traj._wildcard_functions.items()):<EOL><INDENT>wildcards, wc_function = pair<EOL>for jdx, wildcard in enumerate(wildcards):<EOL><INDENT>config_name = ('<STR_LIT>' %<EOL>(self.name, idx, jdx))<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>self._traj.f_add_config(Parameter, config_name, wildcard,<EOL>comment='<STR_LIT>').f_lock()<EOL><DEDENT><DEDENT>if hasattr(wc_function, '<STR_LIT>'):<EOL><INDENT>config_name = ('<STR_LIT>' %<EOL>(self.name, idx))<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>self._traj.f_add_config(Parameter, config_name, wc_function.__name__,<EOL>comment='<STR_LIT>').f_lock()<EOL><DEDENT><DEDENT>if wc_function.__doc__:<EOL><INDENT>config_name = ('<STR_LIT>' %<EOL>(self.name, idx))<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>self._traj.f_add_config(Parameter, config_name, wc_function.__doc__,<EOL>comment='<STR_LIT>').f_lock()<EOL><DEDENT><DEDENT>try:<EOL><INDENT>source = inspect.getsource(wc_function)<EOL>config_name = ('<STR_LIT>' %<EOL>(self.name, idx))<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>self._traj.f_add_config(Parameter, config_name, source,<EOL>comment='<STR_LIT>').f_lock()<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>

Adds config data about the wildcard functions


pypet_root_logger = logging.getLogger('<STR_LIT>')<EOL>traj = kwargs['<STR_LIT>']<EOL>runfunc = kwargs['<STR_LIT>']<EOL>runargs = kwargs['<STR_LIT>']<EOL>kwrunparams = kwargs['<STR_LIT>']<EOL>clean_up_after_run = kwargs['<STR_LIT>']<EOL>automatic_storing = kwargs['<STR_LIT>']<EOL>wrap_mode = kwargs['<STR_LIT>']<EOL>idx = traj.v_idx<EOL>total_runs = len(traj)<EOL>pypet_root_logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (idx, total_runs))<EOL>traj.f_start_run(turn_into_run=True)<EOL>result = runfunc(traj, *runargs, **kwrunparams)<EOL>if automatic_storing:<EOL><INDENT>traj.f_store()<EOL><DEDENT>if wrap_mode == pypetconstants.WRAP_MODE_LOCAL:<EOL><INDENT>result = ((traj.v_idx, result),<EOL>traj.f_get_run_information(traj.v_idx, copy=False),<EOL>traj.v_storage_service.references)<EOL>traj.v_storage_service.free_references()<EOL><DEDENT>else:<EOL><INDENT>result = ((traj.v_idx, result),<EOL>traj.f_get_run_information(traj.v_idx, copy=False))<EOL><DEDENT>traj.f_finalize_run(store_meta_data=False,<EOL>clean_up=clean_up_after_run)<EOL>pypet_root_logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (idx, total_runs))<EOL>return result<EOL>

Performs a single run of the experiment.

    :param kwargs: Dict of arguments

        traj: The trajectory containing all parameters set to the corresponding run index.

        runfunc: The user's job function

        runargs: The arguments handed to the user's job function (as *args)

        runkwargs: The keyword arguments handed to the user's job function (as **kwargs)

        clean_up_after_run: Whether to clean up after the run

        automatic_storing: Whether or not the data should be automatically stored

        result_queue: A queue object to store results into in case a pool is used, otherwise None

    :return:

        Results computed by the user's job function which are not stored into the trajectory.
        Returns a nested tuple of run index and result and run information:
        ``((traj.v_idx, result), run_information_dict)``


def _delete_old_scoop_rev_data(old_scoop_rev):<EOL><INDENT>if old_scoop_rev is not None:<EOL><INDENT>try:<EOL><INDENT>elements = shared.elements<EOL>for key in elements:<EOL><INDENT>var_dict = elements[key]<EOL>if old_scoop_rev in var_dict:<EOL><INDENT>del var_dict[old_scoop_rev]<EOL><DEDENT><DEDENT>logging.getLogger('<STR_LIT>').debug('<STR_LIT>'<EOL>'<STR_LIT>' % old_scoop_rev)<EOL><DEDENT>except AttributeError:<EOL><INDENT>logging.getLogger('<STR_LIT>').error('<STR_LIT>'<EOL>'<STR_LIT>' % old_scoop_rev)<EOL><DEDENT><DEDENT><DEDENT>scoop_rev = kwargs.pop('<STR_LIT>')<EOL>try:<EOL><INDENT>old_scoop_rev = _frozen_scoop_single_run.kwargs['<STR_LIT>']<EOL>configured = old_scoop_rev == scoop_rev<EOL><DEDENT>except (AttributeError, KeyError):<EOL><INDENT>old_scoop_rev = None<EOL>configured = False<EOL><DEDENT>if not configured:<EOL><INDENT>_frozen_scoop_single_run.kwargs = shared.getConst(scoop_rev, timeout=<NUM_LIT>)<EOL>frozen_kwargs = _frozen_scoop_single_run.kwargs<EOL>frozen_kwargs['<STR_LIT>'] = scoop_rev<EOL>frozen_kwargs['<STR_LIT>'].v_full_copy = frozen_kwargs['<STR_LIT>']<EOL>if not scoop.IS_ORIGIN:<EOL><INDENT>_configure_niceness(frozen_kwargs)<EOL>_configure_logging(frozen_kwargs, extract=False)<EOL><DEDENT>_delete_old_scoop_rev_data(old_scoop_rev)<EOL>logging.getLogger('<STR_LIT>').info('<STR_LIT>' % str(scoop.worker))<EOL><DEDENT>

Wrapper function that configures a frozen SCOOP set up.

    Deletes of data if necessary.


_pool_single_run.storage_service = kwargs['<STR_LIT>']<EOL>_configure_niceness(kwargs)<EOL>_configure_logging(kwargs, extract=False)<EOL>

Configures the pool and keeps the storage service


def _get_results_from_queue(self, result_queue, results, n, total_runs):

<EOL>while not result_queue.empty():<EOL><INDENT>result = result_queue.get()<EOL>n = self._check_result_and_store_references(result, results, n, total_runs)<EOL><DEDENT>return n<EOL>

Extract all available results from the queue and returns the increased n


def _check_result_and_store_references(self, result, results, n, total_runs):

if result[<NUM_LIT:0>] == sigint_handling.SIGINT:<EOL><INDENT>self._stop_iteration = True<EOL>result = result[<NUM_LIT:1>]  <EOL><DEDENT>if result is not None:<EOL><INDENT>if self._wrap_mode == pypetconstants.WRAP_MODE_LOCAL:<EOL><INDENT>self._multiproc_wrapper.store_references(result[<NUM_LIT:2>])<EOL><DEDENT>self._traj._update_run_information(result[<NUM_LIT:1>])<EOL>results.append(result[<NUM_LIT:0>])<EOL>if self._resumable:<EOL><INDENT>self._trigger_result_snapshot(result[<NUM_LIT:0>:<NUM_LIT:2>])<EOL><DEDENT><DEDENT>self._show_progress(n, total_runs)<EOL>n += <NUM_LIT:1><EOL>return n<EOL>

Checks for SIGINT and if reference wrapping and stores references.


if self._queue is None:<EOL><INDENT>if self._use_manager:<EOL><INDENT>if self._manager is None:<EOL><INDENT>self._manager = multip.Manager()<EOL><DEDENT>self._queue = self._manager.Queue(maxsize=self._queue_maxsize)<EOL><DEDENT>else:<EOL><INDENT>self._queue = multip.Queue(maxsize=self._queue_maxsize)<EOL><DEDENT><DEDENT>self._logger.info('<STR_LIT>')<EOL>queue_handler = QueueStorageServiceWriter(self._storage_service, self._queue,<EOL>self._gc_interval)<EOL>self._queue_process = multip.Process(name='<STR_LIT>', target=_wrap_handling,<EOL>args=(dict(handler=queue_handler,<EOL>logging_manager=self._logging_manager,<EOL>graceful_exit=self._graceful_exit),))<EOL>self._queue_process.start()<EOL>self._queue_wrapper = QueueStorageServiceSender(self._queue)<EOL>self._traj.v_storage_service = self._queue_wrapper<EOL>

Replaces the trajectory's service with a queue sender and starts the queue process.


repr_string = '<STR_LIT>' % (self.__class__.__name__, self.name,<EOL>self.trajectory.v_name)<EOL>return repr_string<EOL>


timestamp = result[<NUM_LIT:1>]['<STR_LIT>']<EOL>timestamp_str = repr(timestamp).replace('<STR_LIT:.>', '<STR_LIT:_>')<EOL>filename = '<STR_LIT>' % timestamp_str<EOL>extension = '<STR_LIT>'<EOL>dump_filename = os.path.join(self._resume_path, filename + extension)<EOL>dump_file = open(dump_filename, '<STR_LIT:wb>')<EOL>dill.dump(result, dump_file, protocol=<NUM_LIT:2>)<EOL>dump_file.flush()<EOL>dump_file.close()<EOL>extension = '<STR_LIT>'<EOL>rename_filename = os.path.join(self._resume_path, filename + extension)<EOL>shutil.move(dump_filename, rename_filename)<EOL>

Triggers a snapshot of the results for continuing

        :param result: Currently computed result


return self._current_idx<EOL>

The current run index that is the next one to be executed.

        Can be set manually to make the environment consider old non-completed ones.


try:<EOL><INDENT>logging_manager = kwargs['<STR_LIT>']<EOL>if extract:<EOL><INDENT>logging_manager.extract_replacements(kwargs['<STR_LIT>'])<EOL><DEDENT>logging_manager.make_logging_handlers_and_tools(multiproc=True)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>sys.stderr.write('<STR_LIT>' % repr(exc))<EOL>traceback.print_exc()<EOL><DEDENT>

Requests the logging manager to configure logging.

    :param extract:

        If naming data should be extracted from the trajectory


reason = self._sumatra_reason<EOL>if reason:<EOL><INDENT>reason += '<STR_LIT>'<EOL><DEDENT>if self._traj.v_comment:<EOL><INDENT>commentstr = '<STR_LIT>' % self._traj.v_comment<EOL><DEDENT>else:<EOL><INDENT>commentstr = '<STR_LIT>'<EOL><DEDENT>reason += '<STR_LIT>' %(self._traj.v_name,<EOL>commentstr,<EOL>str(list(self._traj._explored_parameters.keys())))<EOL>self._logger.info('<STR_LIT>' % reason)<EOL>self._sumatra_reason = reason<EOL>self._loaded_sumatatra_project = load_project(self._sumatra_project)<EOL>if self._traj.f_contains('<STR_LIT>', shortcuts=False):<EOL><INDENT>param_dict = self._traj.parameters.f_to_dict(fast_access=False)<EOL>for param_name in list(param_dict.keys()):<EOL><INDENT>param = param_dict[param_name]<EOL>if param.f_has_range():<EOL><INDENT>param_dict[param_name] = param.f_get_range()<EOL><DEDENT>else:<EOL><INDENT>param_dict[param_name] = param.f_get()<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>param_dict = {}<EOL><DEDENT>relpath = os.path.relpath(sys.modules['<STR_LIT:__main__>'].__file__, self._sumatra_project)<EOL>executable = PythonExecutable(path=sys.executable)<EOL>self._sumatra_record = self._loaded_sumatatra_project.new_record(<EOL>parameters=param_dict,<EOL>main_file=relpath,<EOL>executable=executable,<EOL>label=self._sumatra_label,<EOL>reason=reason)<EOL>


return self.trajectory<EOL>


finish_time = self._start_timestamp - self._finish_timestamp<EOL>self._sumatra_record.duration = finish_time<EOL>self._sumatra_record.output_data = self._sumatra_record.datastore.find_new_data(<EOL>self._sumatra_record.timestamp)<EOL>self._loaded_sumatatra_project.add_record(self._sumatra_record)<EOL>self._loaded_sumatatra_project.save()<EOL>sumatra_label = self._sumatra_record.label<EOL>config_name = '<STR_LIT>' % str(sumatra_label)<EOL>conf_list = []<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>conf1 = self._traj.f_add_config(Parameter, config_name, str(sumatra_label),<EOL>comment='<STR_LIT>')<EOL>conf_list.append(conf1)<EOL><DEDENT>if self._sumatra_reason:<EOL><INDENT>config_name = '<STR_LIT>' % str(sumatra_label)<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>conf2 = self._traj.f_add_config(Parameter, config_name,<EOL>str(self._sumatra_reason),<EOL>comment='<STR_LIT>')<EOL>conf_list.append(conf2)<EOL><DEDENT><DEDENT>if self._automatic_storing and conf_list:<EOL><INDENT>self._traj.f_store_items(conf_list)<EOL><DEDENT>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT:%s>' % str(self._sumatra_reason))<EOL>


if self._start_timestamp is None:<EOL><INDENT>self._start_timestamp = time.time()<EOL><DEDENT>if self._map_arguments and self._resumable:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if self._sumatra_project is not None:<EOL><INDENT>self._prepare_sumatra()<EOL><DEDENT>if pipeline is not None:<EOL><INDENT>results = []<EOL>self._prepare_runs(pipeline)<EOL><DEDENT>else:<EOL><INDENT>results = self._prepare_resume()<EOL><DEDENT>if self._runfunc is not None:<EOL><INDENT>self._traj._run_by_environment = True<EOL>if self._graceful_exit:<EOL><INDENT>sigint_handling.start()<EOL><DEDENT>try:<EOL><INDENT>self._inner_run_loop(results)<EOL><DEDENT>finally:<EOL><INDENT>self._traj._run_by_environment = False<EOL>self._stop_iteration = False<EOL>if self._graceful_exit:<EOL><INDENT>sigint_handling.finalize()<EOL><DEDENT><DEDENT><DEDENT>self._add_wildcard_config()<EOL>if self._automatic_storing:<EOL><INDENT>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>self._traj.v_name)<EOL>self._traj.f_store()<EOL>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>self._traj.v_name)<EOL><DEDENT>self._finish_timestamp = time.time()<EOL>findatetime = datetime.datetime.fromtimestamp(self._finish_timestamp)<EOL>startdatetime = datetime.datetime.fromtimestamp(self._start_timestamp)<EOL>self._runtime = str(findatetime - startdatetime)<EOL>conf_list = []<EOL>config_name = '<STR_LIT>' % self.name<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>conf1 = self._traj.f_add_config(Parameter, config_name, self._start_timestamp,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>conf_list.append(conf1)<EOL><DEDENT>config_name = '<STR_LIT>' % self.name<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>conf2 = self._traj.f_add_config(Parameter, config_name, self._finish_timestamp,<EOL>comment='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>conf2 = self._traj.f_get('<STR_LIT>' + config_name)<EOL>conf2.f_unlock()<EOL>conf2.f_set(self._finish_timestamp)<EOL><DEDENT>conf_list.append(conf2)<EOL>config_name = '<STR_LIT>' % self.name<EOL>if not self._traj.f_contains('<STR_LIT>' + config_name):<EOL><INDENT>conf3 = self._traj.f_add_config(Parameter, config_name, self._runtime,<EOL>comment='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>conf3 = self._traj.f_get('<STR_LIT>' + config_name)<EOL>conf3.f_unlock()<EOL>conf3.f_set(self._runtime)<EOL><DEDENT>conf_list.append(conf3)<EOL>if self._automatic_storing:<EOL><INDENT>self._traj.f_store_items(conf_list, store_data=pypetconstants.OVERWRITE_DATA)<EOL><DEDENT>if hasattr(self._traj.v_storage_service, '<STR_LIT>'):<EOL><INDENT>self._traj.v_storage_service.finalize()<EOL><DEDENT>incomplete = []<EOL>for run_name in self._traj.f_get_run_names():<EOL><INDENT>if not self._traj._is_completed(run_name):<EOL><INDENT>incomplete.append(run_name)<EOL><DEDENT><DEDENT>if len(incomplete) > <NUM_LIT:0>:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>' % (self._traj.v_name,<EOL>'<STR_LIT:U+002CU+0020>'.join(incomplete)))<EOL><DEDENT>else:<EOL><INDENT>self._logger.info('<STR_LIT>' %<EOL>self._traj.v_name)<EOL><DEDENT>if self._sumatra_project is not None:<EOL><INDENT>self._finish_sumatra()<EOL><DEDENT>return results<EOL>

Starts the individual single runs.

        Starts runs sequentially or initiates multiprocessing.

        :param pipeline:

            A pipeline function producing the run function the corresponding arguments
            and postprocessing function and arguments

        :return:

            List of tuples, where each tuple contains the run idx and the result.


idx = kwargs.pop('<STR_LIT>')<EOL>frozen_kwargs = _frozen_pool_single_run.kwargs<EOL>frozen_kwargs.update(kwargs)  <EOL>traj = frozen_kwargs['<STR_LIT>']<EOL>traj.f_set_crun(idx)<EOL>return _sigint_handling_single_run(frozen_kwargs)<EOL>

Single run wrapper for the frozen pool, makes a single run and passes kwargs


result = set()<EOL>result.update(dir(self.__class__), self.__all_slots__)<EOL>if hasattr(self, '<STR_LIT>'):<EOL><INDENT>result.update(self.__dict__.keys())<EOL><DEDENT>return list(result)<EOL>


self.f_set(**{key: value})<EOL>

Almost equivalent to calling __setattr__.

        Treats integer values as `f_get`.


return len(self._dict) == <NUM_LIT:0><EOL>


return self.f_get(item)<EOL>


if len(args) == <NUM_LIT:0>:<EOL><INDENT>if len(self._dict) == <NUM_LIT:1>:<EOL><INDENT>return self._dict[list(self._dict.keys())[<NUM_LIT:0>]]<EOL><DEDENT>elif len(self._dict) > <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(str(list(self._dict.keys()))))<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>')<EOL><DEDENT><DEDENT>result_list = []<EOL>for name in args:<EOL><INDENT>name = self._translate_key(name)<EOL>try:<EOL><INDENT>result_list.append(self._dict[name])<EOL><DEDENT>except KeyError:<EOL><INDENT>raise AttributeError('<STR_LIT>' % name)<EOL><DEDENT><DEDENT>if len(args) == <NUM_LIT:1>:<EOL><INDENT>return result_list[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return tuple(result_list)<EOL><DEDENT>

Returns annotations

        If len(args)>1, then returns a list of annotations.

        `f_get(X)` with *X* integer will return the annotation with name `annotation_X`.

        If the annotation contains only a single entry you can call `f_get()` without arguments.
        If you call `f_get()` and the annotation contains more than one element a ValueError is
        thrown.


return self._annotations<EOL>

Annotation feature of a trajectory node.

        Store some short additional information about your nodes here.
        If you use the standard HDF5 storage service, they will be stored as hdf5 node
        attributes_.

        .. _attributes: http://pytables.github.io/usersguide/libref/declarative_classes.html#the-attributeset-class


if self.report_progress:<EOL><INDENT>if self.report_progress is True:<EOL><INDENT>self.report_progress = (<NUM_LIT:5>, '<STR_LIT>', logging.INFO)<EOL><DEDENT>elif isinstance(self.report_progress, (int, float)):<EOL><INDENT>self.report_progress = (self.report_progress, '<STR_LIT>', logging.INFO)<EOL><DEDENT>elif isinstance(self.report_progress, str):<EOL><INDENT>self.report_progress = (<NUM_LIT:5>, self.report_progress, logging.INFO)<EOL><DEDENT>elif len(self.report_progress) == <NUM_LIT:2>:<EOL><INDENT>self.report_progress = (self.report_progress[<NUM_LIT:0>], self.report_progress[<NUM_LIT:1>],<EOL>logging.INFO)<EOL><DEDENT><DEDENT>if self.log_config:<EOL><INDENT>if self.log_config == pypetconstants.DEFAULT_LOGGING:<EOL><INDENT>pypet_path = os.path.abspath(os.path.dirname(__file__))<EOL>init_path = os.path.join(pypet_path, '<STR_LIT>')<EOL>self.log_config = os.path.join(init_path, '<STR_LIT>')<EOL><DEDENT>if isinstance(self.log_config, str):<EOL><INDENT>if not os.path.isfile(self.log_config):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % self.log_config)<EOL><DEDENT>parser = NoInterpolationParser()<EOL>parser.read(self.log_config)<EOL><DEDENT>elif isinstance(self.log_config, cp.RawConfigParser):<EOL><INDENT>parser = self.log_config<EOL><DEDENT>else:<EOL><INDENT>parser = None<EOL><DEDENT>if parser is not None:<EOL><INDENT>self._sp_config = self._parser_to_string_io(parser)<EOL>self._mp_config = self._find_multiproc_options(parser)<EOL>if self._mp_config is not None:<EOL><INDENT>self._mp_config = self._parser_to_string_io(self._mp_config)<EOL><DEDENT><DEDENT>elif isinstance(self.log_config, dict):<EOL><INDENT>self._sp_config = self.log_config<EOL>self._mp_config = self._find_multiproc_dict(self._sp_config)<EOL><DEDENT><DEDENT>if self.log_stdout:<EOL><INDENT>if self.log_stdout is True:<EOL><INDENT>self.log_stdout = ('<STR_LIT>', logging.INFO)<EOL><DEDENT>if isinstance(self.log_stdout, str):<EOL><INDENT>self.log_stdout = (self.log_stdout, logging.INFO)<EOL><DEDENT>if isinstance(self.log_stdout, int):<EOL><INDENT>self.log_stdout = ('<STR_LIT>', self.log_stdout)<EOL><DEDENT><DEDENT>

Checks and converts all settings if necessary passed to the Manager.

        Searches for multiprocessing options as well.


log_stdout = self.log_stdout<EOL>if sys.stdout is self._stdout_to_logger:<EOL><INDENT>log_stdout = False<EOL><DEDENT>if self.log_config:<EOL><INDENT>if multiproc:<EOL><INDENT>proc_log_config = self._mp_config<EOL><DEDENT>else:<EOL><INDENT>proc_log_config = self._sp_config<EOL><DEDENT>if proc_log_config:<EOL><INDENT>if isinstance(proc_log_config, dict):<EOL><INDENT>new_dict = self._handle_dict_config(proc_log_config)<EOL>dictConfig(new_dict)<EOL><DEDENT>else:<EOL><INDENT>parser = self._handle_config_parsing(proc_log_config)<EOL>memory_file = self._parser_to_string_io(parser)<EOL>fileConfig(memory_file, disable_existing_loggers=False)<EOL><DEDENT><DEDENT><DEDENT>if log_stdout:<EOL><INDENT>std_name, std_level = self.log_stdout<EOL>stdout = StdoutToLogger(std_name, log_level=std_level)<EOL>stdout.start()<EOL>self._tools.append(stdout)<EOL><DEDENT>

Creates logging handlers and redirects stdout.


log_levels = kwargs.pop('<STR_LIT>', None)<EOL>log_folder = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>logger_names = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>if log_levels is None:<EOL><INDENT>log_levels = kwargs.pop('<STR_LIT>', logging.INFO)<EOL><DEDENT>log_multiproc = kwargs.pop('<STR_LIT>', True)<EOL>if not isinstance(logger_names, (tuple, list)):<EOL><INDENT>logger_names = [logger_names]<EOL><DEDENT>if not isinstance(log_levels, (tuple, list)):<EOL><INDENT>log_levels = [log_levels]<EOL><DEDENT>if len(log_levels) == <NUM_LIT:1>:<EOL><INDENT>log_levels = [log_levels[<NUM_LIT:0>] for _ in logger_names]<EOL><DEDENT>dictionary = copy.deepcopy(LOGGING_DICT)<EOL>prefixes = ['<STR_LIT>']<EOL>if not log_multiproc:<EOL><INDENT>for key in list(dictionary.keys()):<EOL><INDENT>if key.startswith('<STR_LIT>'):<EOL><INDENT>del dictionary[key]<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>prefixes.append('<STR_LIT>')<EOL><DEDENT>for prefix in prefixes:<EOL><INDENT>for handler_dict in dictionary[prefix + '<STR_LIT>'].values():<EOL><INDENT>if '<STR_LIT:filename>' in handler_dict:<EOL><INDENT>filename = os.path.join(log_folder, handler_dict['<STR_LIT:filename>'])<EOL>filename = os.path.normpath(filename)<EOL>handler_dict['<STR_LIT:filename>'] = filename<EOL><DEDENT><DEDENT>dictionary[prefix + '<STR_LIT>'] = {}<EOL>logger_dict = dictionary[prefix + '<STR_LIT>']<EOL>for idx, logger_name in enumerate(logger_names):<EOL><INDENT>logger_dict[logger_name] = {<EOL>'<STR_LIT>': log_levels[idx],<EOL>'<STR_LIT>': list(dictionary[prefix + '<STR_LIT>'].keys())<EOL>}<EOL><DEDENT><DEDENT>kwargs['<STR_LIT>'] = dictionary<EOL>

Helper function to turn the simple logging kwargs into a `log_config`.


pass<EOL>


if self._original_steam is not None and self._redirection:<EOL><INDENT>sys.stdout = self._original_steam<EOL>print('<STR_LIT>')<EOL>self._redirection = False<EOL>self._original_steam = None<EOL><DEDENT>


@functools.wraps(func)<EOL>def new_func(self, *args, **kwargs):<EOL><INDENT>if use_simple_logging(kwargs):<EOL><INDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>_change_logging_kwargs(kwargs)<EOL><DEDENT>return func(self, *args, **kwargs)<EOL><DEDENT>return new_func<EOL>

Decorator to allow a simple logging configuration.

    This encompasses giving a `log_folder`, `logger_names` as well as `log_levels`.


if self.report_progress:<EOL><INDENT>percentage, logger_name, log_level = self.report_progress<EOL>if logger_name == '<STR_LIT>':<EOL><INDENT>logger = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>logger = logging.getLogger(logger_name)<EOL><DEDENT>if n == -<NUM_LIT:1>:<EOL><INDENT>digits = int(math.log10(total_runs + <NUM_LIT:0.1>)) + <NUM_LIT:1><EOL>self._format_string = '<STR_LIT>' + '<STR_LIT>' % digits + '<STR_LIT>'<EOL><DEDENT>fmt_string = self._format_string % (n + <NUM_LIT:1>, total_runs) + '<STR_LIT:%s>'<EOL>reprint = log_level == <NUM_LIT:0><EOL>progressbar(n, total_runs, percentage_step=percentage,<EOL>logger=logger, log_level=log_level,<EOL>fmt_string=fmt_string, reprint=reprint)<EOL><DEDENT>


memory_file = StringIO()<EOL>parser.write(memory_file)<EOL>memory_file.flush()<EOL>memory_file.seek(<NUM_LIT:0>)<EOL>return memory_file<EOL>

Turns a ConfigParser into a StringIO stream.


return self._standard_result<EOL>

The standard result class used for result creation


Changes the index to make the trajectory behave as a single run


return self._with_links<EOL>

Whether links should be considered in case using natural naming
        or squared bracket indexing


def _merge_links(self, other_trajectory, used_runs, allowed_translations, ignore_data):

linked_items = other_trajectory._linked_by<EOL>run_name_dummys = set([f(-<NUM_LIT:1>) for f in other_trajectory._wildcard_functions.values()])<EOL>if len(linked_items) > <NUM_LIT:0>:<EOL><INDENT>self._logger.info('<STR_LIT>')<EOL>for old_linked_name in other_trajectory._linked_by:<EOL><INDENT>if old_linked_name in ignore_data:<EOL><INDENT>continue<EOL><DEDENT>split_name = old_linked_name.split('<STR_LIT:.>')<EOL>if any(x in run_name_dummys for x in split_name):<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(old_linked_name, str(run_name_dummys)))<EOL>continue<EOL><DEDENT>old_link_dict = other_trajectory._linked_by[old_linked_name]<EOL>split_name = old_linked_name.split('<STR_LIT:.>')<EOL>if all(x in allowed_translations for x in split_name):<EOL><INDENT>new_linked_full_name = self._rename_full_name(old_linked_name,<EOL>other_trajectory,<EOL>used_runs=used_runs)<EOL><DEDENT>else:<EOL><INDENT>new_linked_full_name = old_linked_name<EOL><DEDENT>for linking_node, link_set in old_link_dict.values():<EOL><INDENT>linking_full_name = linking_node.v_full_name<EOL>split_name = linking_full_name .split('<STR_LIT:.>')<EOL>if any(x in run_name_dummys for x in split_name):<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(linking_full_name, str(run_name_dummys)))<EOL><DEDENT>split_name = linking_full_name .split('<STR_LIT:.>')<EOL>if any(x in allowed_translations for x in split_name):<EOL><INDENT>new_linking_full_name = self._rename_full_name(linking_full_name,<EOL>other_trajectory,<EOL>used_runs=used_runs)<EOL><DEDENT>else:<EOL><INDENT>new_linking_full_name = linking_full_name<EOL><DEDENT>for link in link_set:<EOL><INDENT>if (linking_full_name + '<STR_LIT:.>' + link) in ignore_data:<EOL><INDENT>continue<EOL><DEDENT>if link in run_name_dummys:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(link,<EOL>linking_full_name,<EOL>str(run_name_dummys)))<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>new_linked_item = self.f_get(new_linked_full_name,<EOL>shortcuts=False)<EOL>if self.f_contains(new_linking_full_name):<EOL><INDENT>new_linking_item = self.f_get(new_linking_full_name,<EOL>shortcuts=False)<EOL><DEDENT>else:<EOL><INDENT>new_linking_item =  self.f_add_group(new_linking_full_name)<EOL><DEDENT>if link in allowed_translations:<EOL><INDENT>run_indices, wildcards = other_trajectory._reversed_wildcards[link]<EOL>link = self.f_wildcard(wildcards[<NUM_LIT:0>], used_runs[run_indices[<NUM_LIT:0>]])<EOL><DEDENT>if not link in new_linking_item._links:<EOL><INDENT>new_linking_item.f_add_link(link, new_linked_item)<EOL><DEDENT>else:<EOL><INDENT>self._logger.debug('<STR_LIT>' %<EOL>(link, new_linked_item.v_full_name))<EOL><DEDENT><DEDENT>except (AttributeError, ValueError) as exc:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(link, linking_full_name, old_linked_name,<EOL>repr(exc)))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>


return self._comment<EOL>


if self.f_contains(name, shortcuts=False):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % name)<EOL><DEDENT>else:<EOL><INDENT>self._changed_default_parameters[name] = (args, kwargs)<EOL><DEDENT>

Generic preset function, marks a parameter or config for presetting.


return self.f_copy(copy_leaves=True,<EOL>with_links=True)<EOL>


comment = str(comment)<EOL>self._comment = comment<EOL>


def _check_if_both_have_same_parameters(self, other_trajectory,<EOL>ignore_data, consecutive_merge):

if not isinstance(other_trajectory, Trajectory):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % str(type(other_trajectory)))<EOL><DEDENT>if self._stored and not consecutive_merge:<EOL><INDENT>self.f_load_skeleton()<EOL><DEDENT>if other_trajectory._stored:<EOL><INDENT>other_trajectory.f_load_skeleton()<EOL><DEDENT>other_wildcard_set = set(x[<NUM_LIT:1>] for x in other_trajectory._wildcard_functions.keys())<EOL>wildcard_set = set(x[<NUM_LIT:1>] for x in self._wildcard_functions.keys())<EOL>diff = wildcard_set.symmetric_difference(other_wildcard_set)<EOL>if diff:<EOL><INDENT>raise TypeError('<STR_LIT>' %<EOL>(str(wildcard_set), str(other_wildcard_set)))<EOL><DEDENT>if self._stored:<EOL><INDENT>with self._nn_interface._disable_logging:<EOL><INDENT>self.f_load_items(self._parameters.keys(), only_empties=True)<EOL><DEDENT><DEDENT>if other_trajectory._stored:<EOL><INDENT>with self._nn_interface._disable_logging:<EOL><INDENT>other_trajectory.f_load_items(other_trajectory._parameters.keys(),<EOL>only_empties=True)<EOL><DEDENT><DEDENT>self.f_restore_default()<EOL>other_trajectory.f_restore_default()<EOL>allmyparams = self._parameters.copy()<EOL>allotherparams = other_trajectory._parameters.copy()<EOL>if '<STR_LIT>' in self:<EOL><INDENT>my_traj_dpars = self._derived_parameters<EOL>if self._stored:<EOL><INDENT>with self._nn_interface._disable_logging:<EOL><INDENT>self.f_load_items(my_traj_dpars.keys(), only_empties=True)<EOL><DEDENT><DEDENT>allmyparams.update(my_traj_dpars)<EOL>other_traj_dpars = other_trajectory._derived_parameters<EOL>if other_trajectory._stored:<EOL><INDENT>with self._nn_interface._disable_logging:<EOL><INDENT>other_trajectory.f_load_items(other_traj_dpars.keys(), only_empties=True)<EOL><DEDENT><DEDENT>allotherparams.update(other_traj_dpars)<EOL><DEDENT>my_keyset = set(allmyparams.keys())<EOL>other_keyset = set(allotherparams.keys())<EOL>diff = my_keyset.symmetric_difference(other_keyset) - ignore_data<EOL>run_dummys = (self.f_wildcard('<STR_LIT:$>', -<NUM_LIT:1>), other_trajectory.f_wildcard('<STR_LIT:$>', -<NUM_LIT:1>))<EOL>if diff:<EOL><INDENT>run_difference_can_be_resolved = True<EOL>for full_name in diff:<EOL><INDENT>split_name = full_name.split('<STR_LIT:.>')<EOL>if not any(x in self._run_information or<EOL>x in other_trajectory._run_information or<EOL>x in run_dummys<EOL>for x in split_name):<EOL><INDENT>run_difference_can_be_resolved = False<EOL>break<EOL><DEDENT>elif full_name in allotherparams:<EOL><INDENT>del allotherparams[full_name]<EOL><DEDENT><DEDENT>if not run_difference_can_be_resolved:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % str(diff))<EOL><DEDENT><DEDENT>for key, other_param in allotherparams.items():<EOL><INDENT>if key in ignore_data:<EOL><INDENT>continue<EOL><DEDENT>my_param = self.f_get(key)<EOL>split_key = key.split('<STR_LIT:.>')<EOL>if any(x in self._run_information or<EOL>x in other_trajectory._run_information<EOL>for x in split_key):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if not my_param._values_of_same_type(my_param.f_get(), other_param.f_get()):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(key, str(type(my_param.f_get())),<EOL>str(type(other_param.f_get()))))<EOL><DEDENT><DEDENT><DEDENT>

Checks if two trajectories live in the same space and can be merged.


return list(self._wildcard_keys.keys())<EOL>


self._idx = -<NUM_LIT:1><EOL>self._crun = None<EOL>for param in self._explored_parameters.values():<EOL><INDENT>if param is not None:<EOL><INDENT>param._restore_default()<EOL><DEDENT><DEDENT>

Restores the default value in all explored parameters and sets the
        v_idx property back to -1 and v_crun to None.


if self._stored and not force:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>for param in self._explored_parameters.values():<EOL><INDENT>param.f_unlock()<EOL>try:<EOL><INDENT>param._shrink()<EOL><DEDENT>except Exception as exc:<EOL><INDENT>self._logger.error('<STR_LIT>' %<EOL>(param.v_full_name, repr(exc)))<EOL><DEDENT><DEDENT>self._explored_parameters = {}<EOL>self._run_information = {}<EOL>self._single_run_ids = {}<EOL>self._add_run_info(<NUM_LIT:0>)<EOL>self._test_run_addition(<NUM_LIT:1>)<EOL>

Shrinks the trajectory and removes all exploration ranges from the parameters.
        Only possible if the trajectory has not been stored to disk before or was loaded as new.

        :param force:

            Usually you cannot shrink the trajectory if it has been stored to disk,
            because there's no guarantee that it is actually shrunk if there
            still exist explored parameters on disk. In case you are certain that
            you did not store explored parameters to disk set or you deleted all
            of them from disk set `force=True`.

        :raises: TypeError if the trajectory was stored before.


def f_delete_link(self, link, remove_from_trajectory=False):

self.f_delete_links((link,), remove_from_trajectory)<EOL>

Deletes a single link see :func:`~pypet.trajectory.Trajectory.f_delete_links`