INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Stores references to disk and may collect garbage.
def store_references(self, references): """Stores references to disk and may collect garbage.""" for trajectory_name in references: self._storage_service.store(pypetconstants.LIST, references[trajectory_name], trajectory_name=trajectory_name) self._check_and_collect_garbage()
Decorator wrapping the environment to use a config file
def parse_config(init_func): """Decorator wrapping the environment to use a config file""" @functools.wraps(init_func) def new_func(env, *args, **kwargs): config_interpreter = ConfigInterpreter(kwargs) # Pass the config data to the kwargs new_kwargs = config_interpreter.interpret() ...
Collects all settings within a section
def _collect_section(self, section): """Collects all settings within a section""" kwargs = {} try: if self.parser.has_section(section): options = self.parser.options(section) for option in options: str_val = self.parser.get(section,...
Collects all info from three sections
def _collect_config(self): """Collects all info from three sections""" kwargs = {} sections = ('storage_service', 'trajectory', 'environment') for section in sections: kwargs.update(self._collect_section(section)) return kwargs
Copies parsed arguments into the kwargs passed to the environment
def interpret(self): """Copies parsed arguments into the kwargs passed to the environment""" if self.config_file: new_kwargs = self._collect_config() for key in new_kwargs: # Already specified kwargs take precedence over the ini file if key not in ...
Adds parameters and config from the. ini file to the trajectory
def add_parameters(self, traj): """Adds parameters and config from the `.ini` file to the trajectory""" if self.config_file: parameters = self._collect_section('parameters') for name in parameters: value = parameters[name] if not isinstance(value, ...
Converts a rule given as an integer into a binary list representation.
def convert_rule(rule_number): """ Converts a rule given as an integer into a binary list representation. It reads from left to right (contrary to the Wikipedia article given below), i.e. the 2**0 is found on the left hand side and 2**7 on the right. For example: ``convert_rule(30)`` returns ...
Creates an initial state for the automaton.
def make_initial_state(name, ncells, seed=42): """ Creates an initial state for the automaton. :param name: Either ``'single'`` for a single live cell in the middle of the cell ring, or ``'random'`` for uniformly distributed random pattern of zeros and ones. :param ncells: Number of cells...
Plots an automaton pattern and stores the image under a given filename.
def plot_pattern(pattern, rule_number, filename): """ Plots an automaton ``pattern`` and stores the image under a given ``filename``. For axes labels the ``rule_number`` is also required. """ plt.figure() plt.imshow(pattern) plt.xlabel('Cell No.') plt.ylabel('Time Step') plt.title('CA ...
Simulates a 1 dimensional cellular automaton.
def cellular_automaton_1D(initial_state, rule_number, steps): """ Simulates a 1 dimensional cellular automaton. :param initial_state: The initial state of *dead* and *alive* cells as a 1D numpy array. It's length determines the size of the simulation. :param rule_number: The upda...
Main simulation function
def main(): """ Main simulation function """ rules_to_test = [10, 30, 90, 110, 184] # rules we want to explore: steps = 250 # cell iterations ncells = 400 # number of cells seed = 100042 # RNG seed initial_states = ['single', 'random'] # Initial states we want to explore # create a fol...
Iterates through a class ( cls ) mro to get all slots as a set.
def get_all_slots(cls): """Iterates through a class' (`cls`) mro to get all slots as a set.""" slots_iterator = (getattr(c, '__slots__', ()) for c in cls.__mro__) # `__slots__` might only be a single string, # so we need to put the strings into a tuple. slots_converted = ((slots,) if isinstance(slot...
Signals the process timer.
def signal_update(self): """Signals the process timer. If more time than the display time has passed a message is emitted. """ if not self.active: return self._updates += 1 current_time = time.time() dt = current_time - self._last_time if dt...
Direct link to the overview group
def _overview_group(self): """Direct link to the overview group""" if self._overview_group_ is None: self._overview_group_ = self._all_create_or_get_groups('overview')[0] return self._overview_group_
Makes filters
def _all_get_filters(self, kwargs=None): """Makes filters Pops filter arguments from `kwargs` such that they are not passed on to other functions also using kwargs. """ if kwargs is None: kwargs = {} complib = kwargs.pop('complib', None) complevel = ...
Sets a config value to the Trajectory or changes it if the trajectory was loaded a the settings no longer match
def _srvc_set_config(self, trajectory): """Sets a config value to the Trajectory or changes it if the trajectory was loaded a the settings no longer match""" def _set_config(name, value, comment): if not trajectory.f_contains('config.'+name, shortcuts=False): trajecto...
Loads a particular item from disk.
def load(self, msg, stuff_to_load, *args, **kwargs): """Loads a particular item from disk. The storage service always accepts these parameters: :param trajectory_name: Name of current trajectory and name of top node in hdf5 file. :param trajectory_index: If no `trajectory...
Stores a particular item to disk.
def store(self, msg, stuff_to_store, *args, **kwargs): """ Stores a particular item to disk. The storage service always accepts these parameters: :param trajectory_name: Name or current trajectory and name of top node in hdf5 file :param filename: Name of the hdf5 file :param...
Loads several items from an iterable
def _srvc_load_several_items(self, iterable, *args, **kwargs): """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` provi...
Reads out the properties for storing new data into the hdf5file
def _srvc_check_hdf_properties(self, traj): """Reads out the properties for storing new data into the hdf5file :param traj: The trajectory """ for attr_name in HDF5StorageService.ATTR_LIST: try: config = traj.f_get('config.hdf5.' + attr_name).f...
Stores several items from an iterable
def _srvc_store_several_items(self, iterable, *args, **kwargs): """Stores 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` pro...
Opens an hdf5 file for reading or writing
def _srvc_opening_routine(self, mode, msg=None, kwargs=()): """Opens an hdf5 file for reading or writing The file is only opened if it has not been opened before (i.e. `self._hdf5file is None`). :param mode: 'a' for appending 'r' for reading Unfortuna...
Routine to close an hdf5 file
def _srvc_closing_routine(self, closing): """Routine to close an hdf5 file The file is closed only when `closing=True`. `closing=True` means that the file was opened in the current highest recursion level. This prevents re-opening and closing of the file if `store` or `load` are called ...
Extracts file information from kwargs.
def _srvc_extract_file_information(self, kwargs): """Extracts file information from kwargs. Note that `kwargs` is not passed as `**kwargs` in order to also `pop` the elements on the level of the function calling `_srvc_extract_file_information`. """ if 'filename' in kwargs: ...
Backs up a trajectory.
def _trj_backup_trajectory(self, traj, backup_filename=None): """Backs up a trajectory. :param traj: Trajectory that should be backed up :param backup_filename: Path and filename of backup file. If None is specified the storage service defaults to `path_to_trajectory_h...
Reads out a row and returns a dictionary containing the row content.
def _trj_read_out_row(colnames, row): """Reads out a row and returns a dictionary containing the row content. :param colnames: List of column names :param row: A pytables table row :return: A dictionary with colnames as keys and content as values """ result_dict = {} ...
Merges another trajectory into the current trajectory ( as in self. _trajectory_name ).
def _trj_merge_trajectories(self, other_trajectory_name, rename_dict, move_nodes=False, delete_trajectory=False, other_filename=None): """Merges another trajectory into the current trajectory (as in self._trajectory_name). :param other_trajectory_name: Name of other traj...
Prepares a trajectory for merging.
def _trj_prepare_merge(self, traj, changed_parameters, old_length): """Prepares a trajectory for merging. This function will already store extended parameters. :param traj: Target of merge :param changed_parameters: List of extended parameters (i.e. their names). """ ...
Loads a single trajectory from a given file.
def _trj_load_trajectory(self, traj, as_new, load_parameters, load_derived_parameters, load_results, load_other_data, recursive, max_depth, with_run_information, with_meta_data, force): """Loads a single trajectory from a given file. :param tra...
Loads meta information about the trajectory
def _trj_load_meta_data(self, traj, load_data, as_new, with_run_information, force): """Loads meta information about the trajectory Checks if the version number does not differ from current pypet version Loads, comment, timestamp, name, version from disk in case trajectory is not loaded ...
Loads data starting from a node along a branch and starts recursively loading all data at end of branch.
def _tree_load_sub_branch(self, traj_node, branch_name, load_data=pypetconstants.LOAD_DATA, with_links=True, recursive=False, max_depth=None, _trajectory=None, _as_new=False, _hdf5_group=None): ...
Checks for version mismatch
def _trj_check_version(self, version, python, force): """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. """ curr_python = py...
Fills the run overview table with information.
def _trj_fill_run_table(self, traj, start, stop): """Fills the `run` overview table with information. Will also update new information. """ def _make_row(info_dict): row = (info_dict['idx'], info_dict['name'], info_dict['time'], ...
Stores general information about the trajectory in the hdf5file.
def _trj_store_meta_data(self, traj): """ Stores general information about the trajectory in the hdf5file. The `info` table will contain the name of the trajectory, it's timestamp, a comment, the length (aka the number of single runs), and the current version number of pypet. Also prep...
Recalls names of all explored parameters
def _trj_load_exploration(self, traj): """Recalls names of all explored parameters""" if hasattr(self._overview_group, 'explorations'): explorations_table = self._overview_group._f_get_child( 'explorations') for row in explorations_table.iterrows(): param_name = r...
Stores a all explored parameter names for internal recall
def _trj_store_explorations(self, traj): """Stores a all explored parameter names for internal recall""" nexplored = len(traj._explored_parameters) if nexplored > 0: if hasattr(self._overview_group, 'explorations'): explorations_table = self._overview_group._f_get_chi...
Creates the overview tables in overview group
def _srvc_make_overview_tables(self, tables_to_make, traj=None): """Creates the overview tables in overview group""" for table_name in tables_to_make: # Prepare the tables desciptions, depending on which overview table we create # we need different columns paramdescri...
Stores a trajectory to an hdf5 file
def _trj_store_trajectory(self, traj, only_init=False, store_data=pypetconstants.STORE_DATA, max_depth=None): """ Stores a trajectory to an hdf5 file Stores all groups, parameters and results """ if not only_init: self._logger.info('Start stori...
Stores data starting from a node along a branch and starts recursively loading all data at end of branch.
def _tree_store_sub_branch(self, traj_node, branch_name, store_data=pypetconstants.STORE_DATA, with_links=True, recursive=False, max_depth=None, hdf5_group=None): ...
Creates a new pypet leaf instance.
def _tree_create_leaf(self, name, trajectory, hdf5_group): """ Creates a new pypet leaf instance. Returns the leaf and if it is an explored parameter the length of the range. """ class_name = self._all_get_from_attrs(hdf5_group, HDF5StorageService.CLASS_NAME) # Create the inst...
Loads a node from hdf5 file and if desired recursively everything below
def _tree_load_nodes_dfs(self, parent_traj_node, load_data, with_links, recursive, max_depth, current_depth, trajectory, as_new, hdf5_group): """Loads a node from hdf5 file and if desired recursively everything below :param parent_traj_node: The parent node whose child should b...
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 _tree_load_link(self, new_traj_node, load_data, traj, as_new, hdf5_soft_link): """ 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...
Stores a node to hdf5 and if desired stores recursively everything below it.
def _tree_store_nodes_dfs(self, parent_traj_node, name, store_data, with_links, recursive, max_depth, current_depth, parent_hdf5_group): """Stores a node to hdf5 and if desired stores recursively everything below it. :param parent_traj_node: The paren...
Creates a soft link.: param node_in_traj: parental node: param store_data: how to store data: param link: name of link: param hdf5_group: current parental hdf5 group
def _tree_store_link(self, node_in_traj, link, hdf5_group): """Creates a soft link. :param node_in_traj: parental node :param store_data: how to store data :param link: name of link :param hdf5_group: current parental hdf5 group """ if hasattr(hdf5_group...
Stores a single run instance to disk ( only meta data )
def _srn_store_single_run(self, traj, recursive=True, store_data=pypetconstants.STORE_DATA, max_depth=None): """ Stores a single run instance to disk (only meta data)""" if store_data != pypetconstants.STORE_NOTHI...
Summarizes the parameter settings.
def _srn_summarize_explored_parameters(self, paramlist): """Summarizes the parameter settings. :param run_name: Name of the single run :param paramlist: List of explored parameters :param add_table: Whether to add the overview table :param create_run_group: If a ...
Stores a single row into an overview table
def _all_store_param_or_result_table_entry(self, instance, table, flags, additional_info=None): """Stores a single row into an overview table :param instance: A parameter or result instance :param table: Table where row will be inserted :...
Creates a new table or if the table already exists returns it.
def _all_get_or_create_table(self, where, tablename, description, expectedrows=None): """Creates a new table, or if the table already exists, returns it.""" where_node = self._hdf5file.get_node(where) if not tablename in where_node: if not expectedrows is None: table...
Returns an HDF5 node by the path specified in name
def _all_get_node_by_name(self, name): """Returns an HDF5 node by the path specified in `name`""" path_name = name.replace('.', '/') where = '/%s/%s' % (self._trajectory_name, path_name) return self._hdf5file.get_node(where=where)
Stores original data type to hdf5 node attributes for preserving the data type.
def _all_set_attributes_to_recall_natives(data, ptitem, prefix): """Stores original data type to hdf5 node attributes for preserving the data type. :param data: Data to be stored :param ptitem: HDF5 node to store data types as attributes. Can also be just a PTItemMock...
Checks if loaded data has the type it was stored in. If not converts it.
def _all_recall_native_type(self, data, ptitem, prefix): """Checks if loaded data has the type it was stored in. If not converts it. :param data: Data item to be checked and converted :param ptitem: HDf5 Node or Leaf from where data was loaded :param prefix: Prefix for recalling the dat...
Adds or changes a row in a pytable.
def _all_add_or_modify_row(self, item_name, insert_dict, table, index=None, condition=None, condvars=None, flags=(ADD_ROW, MODIFY_ROW,)): """Adds or changes a row in a pytable. :param item_name: Name of item, the row is about, only important...
Copies data from insert_dict into a pytables row.
def _all_insert_into_row(self, row, insert_dict): """Copies data from `insert_dict` into a pytables `row`.""" for key, val in insert_dict.items(): try: row[key] = val except KeyError as ke: self._logger.warning('Could not write `%s` into a table, '...
Extracts information from a given item to be stored into a pytable row.
def _all_extract_insert_dict(self, item, colnames, additional_info=None): """Extracts information from a given item to be stored into a pytable row. Items can be a variety of things here, trajectories, single runs, group node, parameters, results. :param item: Item from which data shou...
Cuts string data to the maximum length allowed in a pytables column if string is too long.
def _all_cut_string(string, max_length, logger): """Cuts string data to the maximum length allowed in a pytables column if string is too long. :param string: String to be cut :param max_length: Maximum allowed string length :param logger: Logger where messages about truncating s...
Creates or returns a group
def _all_create_or_get_group(self, name, parent_hdf5_group=None): """Creates or returns a group""" if not name in parent_hdf5_group: new_hdf5_group = self._hdf5file.create_group(where=parent_hdf5_group, name=name, ...
Creates new or follows existing group nodes along a given colon separated key.
def _all_create_or_get_groups(self, key, start_hdf5_group=None): """Creates new or follows existing group nodes along a given colon separated `key`. :param key: Colon separated path along hdf5 file, e.g. `parameters.mobiles.cars`. :param start_hdf5_group: HDF5 group f...
Stores annotations into an hdf5 file.
def _ann_store_annotations(self, item_with_annotations, node, overwrite=False): """Stores annotations into an hdf5 file.""" # If we overwrite delete all annotations first if overwrite is True or overwrite == 'v_annotations': annotated = self._all_get_from_attrs(node, HDF5StorageServ...
Loads annotations from disk.
def _ann_load_annotations(self, item_with_annotations, node): """Loads annotations from disk.""" annotated = self._all_get_from_attrs(node, HDF5StorageService.ANNOTATED) if annotated: annotations = item_with_annotations.v_annotations # You can only load into non-empty...
Stores a group node.
def _grp_store_group(self, traj_group, store_data=pypetconstants.STORE_DATA, with_links=True, recursive=False, max_depth=None, _hdf5_group=None, _newly_created=False): """Stores a group node. For group nodes only annotations and comments need to be stor...
Loads a group node and potentially everything recursively below
def _grp_load_group(self, traj_group, load_data=pypetconstants.LOAD_DATA, with_links=True, recursive=False, max_depth=None, _traj=None, _as_new=False, _hdf5_group=None): """Loads a group node and potentially everything recursively below""" if _hdf5_group i...
Reloads skeleton data of a tree node
def _all_load_skeleton(self, traj_node, hdf5_group): """Reloads skeleton data of a tree node""" if traj_node.v_annotations.f_is_empty(): self._ann_load_annotations(traj_node, hdf5_group) if traj_node.v_comment == '': comment = self._all_get_from_attrs(hdf5_group, HDF5Stor...
Extracts storage flags for data in data_dict if they were not specified in flags_dict.
def _prm_extract_missing_flags(data_dict, flags_dict): """Extracts storage flags for data in `data_dict` if they were not specified in `flags_dict`. See :const:`~pypet.storageservice.HDF5StorageService.TYPE_FLAG_MAPPING` for how to store different types of data per default. """...
Adds data to the summary tables and returns if instance s comment has to be stored.
def _prm_meta_add_summary(self, instance): """Adds data to the summary tables and returns if `instance`s comment has to be stored. Also moves comments upwards in the hierarchy if purge_duplicate_comments is true and a lower index run has completed. Only necessary for *multiprocessing*. ...
Adds information to overview tables and meta information to the instance s hdf5 group.
def _prm_add_meta_info(self, instance, group, overwrite=False): """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 b...
Stores a store_dict
def _prm_store_from_dict(self, fullname, store_dict, hdf5_group, store_flags, kwargs): """Stores a `store_dict`""" for key, data_to_store in store_dict.items(): # self._logger.log(1, 'SUB-Storing %s [%s]', key, str(store_dict[key])) original_hdf5_group = None flag = ...
Stores a parameter or result to hdf5.
def _prm_store_parameter_or_result(self, instance, store_data=pypetconstants.STORE_DATA, store_flags=None, overwrite=None, wi...
Reads a DataFrame from dis.
def _prm_select_shared_pandas_data(self, pd_node, full_name, **kwargs): """Reads a DataFrame from dis. :param pd_node: hdf5 node storing the pandas DataFrame :param full_name: Full name of the parameter or result whose data is to be loaded :param kwargs: ...
Creates and array that can be used with an HDF5 array object
def _prm_write_shared_array(self, key, data, hdf5_group, full_name, flag, **kwargs): """Creates and array that can be used with an HDF5 array object""" if flag == HDF5StorageService.ARRAY: self._prm_write_into_array(key, data, hdf5_group, full_name, **kwargs) elif flag in (HDF5Stora...
Creates a new empty table
def _prm_write_shared_table(self, key, hdf5_group, fullname, **kwargs): """Creates a new empty table""" first_row = None description = None if 'first_row' in kwargs: first_row = kwargs.pop('first_row') if not 'description' in kwargs: description = ...
Stores a python dictionary as pytable
def _prm_write_dict_as_table(self, key, data_to_store, group, fullname, **kwargs): """Stores a python dictionary as pytable :param key: Name of data item to store :param data_to_store: Dictionary to store :param group: Group node where to store d...
Stores a pandas DataFrame into hdf5.
def _prm_write_pandas_data(self, key, data, group, fullname, flag, **kwargs): """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 fi...
Stores data as carray earray or vlarray depending on flag.
def _prm_write_into_other_array(self, key, data, group, fullname, flag, **kwargs): """Stores data as carray, earray or vlarray depending on `flag`. :param key: Name of data item to store :param data: Data to store :param gr...
Stores data as array.
def _prm_write_into_array(self, key, data, group, fullname, **kwargs): """Stores data as array. :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: ...
Removes a link from disk
def _lnk_delete_link(self, link_name): """Removes a link from disk""" translated_name = '/' + self._trajectory_name + '/' + link_name.replace('.','/') link = self._hdf5file.get_node(where=translated_name) link._f_remove()
Removes a parameter or result or group from the hdf5 file.
def _all_delete_parameter_or_result_or_group(self, instance, delete_only=None, remove_from_item=False, recursive=False, _hdf...
Stores data as pytable.
def _prm_write_into_pytable(self, tablename, data, hdf5_group, fullname, **kwargs): """Stores data as pytable. :param tablename: Name of the data table :param data: Data to store :param hdf5_group: Group node where to store data in hdf5 file ...
Returns a description dictionary for pytables table creation
def _prm_make_description(self, data, fullname): """ Returns a description dictionary for pytables table creation""" def _convert_lists_and_tuples(series_of_data): """Converts lists and tuples to numpy arrays""" if isinstance(series_of_data[0], (list, t...
Creates a pytables column instance.
def _all_get_table_col(self, key, column, fullname): """ Creates a pytables column instance. The type of column depends on the type of `column[0]`. Note that data in `column` must be homogeneous! """ val = column[0] try: # # We do not want to loose int_ ...
Returns the longest string size for a string entry across data.
def _prm_get_longest_stringsize(string_list): """ Returns the longest string size for a string entry across data.""" maxlength = 1 for stringar in string_list: if isinstance(stringar, np.ndarray): if stringar.ndim > 0: for string in stringar.ravel...
Loads into dictionary
def _prm_load_into_dict(self, full_name, load_dict, hdf5_group, instance, load_only, load_except, load_flags, _prefix = ''): """Loads into dictionary""" for node in hdf5_group: load_type = self._all_get_from_attrs(node, HDF5StorageService.STORAGE_TYPE) ...
Loads a parameter or result from disk.
def _prm_load_parameter_or_result(self, instance, load_data=pypetconstants.LOAD_DATA, load_only=None, load_except=None, load_flags=None, ...
Loads data that was originally a dictionary when stored
def _prm_read_dictionary(self, leaf, full_name): """Loads data that was originally a dictionary when stored :param leaf: PyTables table containing the dictionary data :param full_name: Full name of the parameter or result whose data is to be loaded :return: ...
Reads shared data and constructs the appropraite class.
def _prm_read_shared_data(self, shared_node, instance): """Reads shared data and constructs the appropraite class. :param shared_node: hdf5 node storing the pandas DataFrame :param full_name: Full name of the parameter or result whose data is to be loaded :re...
Reads a DataFrame from dis.
def _prm_read_pandas(self, pd_node, full_name): """Reads a DataFrame from dis. :param pd_node: hdf5 node storing the pandas DataFrame :param full_name: Full name of the parameter or result whose data is to be loaded :return: Data to load ...
Reads a non - nested PyTables table column by column and created a new ObjectTable for the loaded data.
def _prm_read_table(self, table_or_group, full_name): """Reads a non-nested PyTables table column by column and created a new ObjectTable for the loaded data. :param table_or_group: PyTables table to read from or a group containing subtables. :param full_name: ...
Reads data from an array or carray
def _prm_read_array(self, array, full_name): """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 ...
Helper function that creates a novel trajectory and loads it from disk.
def load_trajectory(name=None, index=None, as_new=False, load_parameters=pypetconstants.LOAD_DATA, load_derived_parameters=pypetconstants.LOAD_SKELETON, load_results=pypetconstants.LOAD_SKELETON, load...
Creates a run set name based on idx
def make_set_name(idx): """Creates a run set name based on ``idx``""" GROUPSIZE = 1000 set_idx = idx // GROUPSIZE if set_idx >= 0: return pypetconstants.FORMATTED_SET_NAME % set_idx else: return pypetconstants.SET_NAME_DUMMY
#TODO
def f_add_wildcard_functions(self, func_dict): """#TODO""" for wildcards, function in func_dict.items(): if not isinstance(wildcards, tuple): wildcards = (wildcards,) for wildcard in wildcards: if wildcard in self._wildcard_keys: ...
#TODO
def f_wildcard(self, wildcard='$', run_idx=None): """#TODO""" if run_idx is None: run_idx = self.v_idx wildcards = self._wildcard_keys[wildcard] try: return self._wildcard_cache[(wildcards, run_idx)] except KeyError: translation = self._wildcar...
Sets full copy mode of trajectory and ( ! ) ALL explored parameters!
def v_full_copy(self, val): """ Sets full copy mode of trajectory and (!) ALL explored parameters!""" self._full_copy = bool(val) for param in self._explored_parameters.values(): if param is not None: param.v_full_copy = bool(val)
Sets properties like v_fast_access.
def f_set_properties(self, **kwargs): """Sets properties like ``v_fast_access``. For example: ``traj.f_set_properties(v_fast_access=True, v_auto_load=False)`` """ for name in kwargs: val = kwargs[name] if not name.startswith('v_'): name = 'v_' + ...
Adds classes or paths to classes to the trajectory to create custom parameters.
def f_add_to_dynamic_imports(self, dynamic_imports): """Adds classes or paths to classes to the trajectory to create custom parameters. :param dynamic_imports: If you've written custom parameter that needs to be loaded dynamically during runtime, this needs to be specified here...
Can make the trajectory behave as during a particular single run.
def f_set_crun(self, name_or_idx): """Can make the trajectory behave as during a particular single run. It allows easier data analysis. Has the following effects: * `v_idx` and `v_crun` are set to the appropriate index and run name * All explored para...
Makes the trajectory iterate over all runs.
def f_iter_runs(self, start=0, stop=None, step=1, yields='name'): """Makes the trajectory iterate over all runs. :param start: Start index of run :param stop: Stop index, leave ``None`` for length of trajectory :param step: Stepsize :param yields: What should be ...
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.
def f_shrink(self, force=False): """ 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 ...
Generic preset function marks a parameter or config for presetting.
def _preset(self, name, args, kwargs): """Generic preset function, marks a parameter or config for presetting.""" if self.f_contains(name, shortcuts=False): raise ValueError('Parameter `%s` is already part of your trajectory, use the normal' 'accessing routine to...
Similar to func: ~pypet. trajectory. Trajectory. f_preset_parameter
def f_preset_config(self, config_name, *args, **kwargs): """Similar to func:`~pypet.trajectory.Trajectory.f_preset_parameter`""" if not config_name.startswith('config.'): config_name = 'config.' + config_name self._preset(config_name, args, kwargs)
Presets parameter value before a parameter is added.
def f_preset_parameter(self, param_name, *args, **kwargs): """Presets parameter value before a parameter is added. Can be called before parameters are added to the Trajectory in order to change the values that are stored into the parameter on creation. After creation of a parameter, th...