INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Called by the environment to make some initial configurations before performing the individual runs. | def _prepare_experiment(self):
"""Called by the environment to make some initial configurations before performing the
individual runs.
Checks if all parameters marked for presetting were preset. If not raises a
DefaultReplacementError.
Locks all parameters.
Removal of ... |
Searches for all occurrences of name in each run. | def f_get_from_runs(self, name, include_default_run=True, use_indices=False,
fast_access=False, with_links = True,
shortcuts=True, max_depth=None, auto_load=False):
"""Searches for all occurrences of `name` in each run.
Generates an ordered dictionary wit... |
Private function such that it can still be called by the environment during a single run | def _is_completed(self, name_or_id=None):
"""Private function such that it can still be called by the environment during
a single run"""
if name_or_id is None:
return all(
(runinfo['completed'] for runinfo in self._run_information.values()))
else:
... |
Similar to: func: ~pypet. trajectory. Trajectory. f_explore but can be used to enlarge already completed trajectories. | def f_expand(self, build_dict, fail_safe=True):
"""Similar to :func:`~pypet.trajectory.Trajectory.f_explore`, but can be used to enlarge
already completed trajectories.
Please ensure before usage, that all explored parameters are loaded!
:param build_dict:
Dictionary conta... |
Called if trajectory is expanded deletes all explored parameters from disk | def _remove_exploration(self):
""" Called if trajectory is expanded, deletes all explored parameters from disk """
for param in self._explored_parameters.values():
if param._stored:
try:
self.f_delete_item(param)
except Exception:
... |
Returns a * shallow * copy of a trajectory. | def f_copy(self, copy_leaves=True,
with_links=True):
"""Returns a *shallow* copy of a trajectory.
:param copy_leaves:
If leaves should be **shallow** copied or simply referred to by both trees.
**Shallow** copying is established using the copy module.
... |
Pass a node to insert the full tree to the trajectory. | def _copy_from(self, node,
copy_leaves=True,
overwrite=False,
with_links=True):
"""Pass a ``node`` to insert the full tree to the trajectory.
Considers all links in the given node!
Ignored nodes already found in the c... |
Prepares the trajectory to explore the parameter space. | def f_explore(self, build_dict):
"""Prepares the trajectory to explore the parameter space.
To explore the parameter space you need to provide a dictionary with the names of the
parameters to explore as keys and iterables specifying the exploration ranges as values.
All iterables need... |
Overwrites the run information of a particular run | def _update_run_information(self, run_information_dict):
"""Overwrites the run information of a particular run"""
idx = run_information_dict['idx']
name = run_information_dict['name']
self._run_information[name] = run_information_dict
self._updated_run_information.add(idx) |
Adds a new run to the _run_information dict. | def _add_run_info(self, idx, name='', timestamp=42.0, finish_timestamp=1.337,
runtime='forever and ever', time='>>Maybe time`s gone on strike',
completed=0, parameter_summary='Not yet my friend!',
short_environment_hexsha='N/A'):
"""Adds a new ru... |
Locks all non - empty parameters | def f_lock_parameters(self):
"""Locks all non-empty parameters"""
for par in self._parameters.values():
if not par.f_is_empty():
par.f_lock() |
Locks all non - empty derived parameters | def f_lock_derived_parameters(self):
"""Locks all non-empty derived parameters"""
for par in self._derived_parameters.values():
if not par.f_is_empty():
par.f_lock() |
Final rollback initiated by the environment | def _finalize(self, store_meta_data=True):
"""Final rollback initiated by the environment
Restores the trajectory as root of the tree, and stores meta data to disk.
This updates the trajectory's information about single runs, i.e. if they've been
completed, when they were started, etc.
... |
Loads the full skeleton from the storage service. | def f_load_skeleton(self):
"""Loads the full skeleton from the storage service.
This needs to be done after a successful exploration in order to update the
trajectory tree with all results and derived parameters from the individual single runs.
This will only add empty results and deriv... |
Loads a trajectory via the storage service. | def f_load(self, name=None, index=None, as_new=False, load_parameters=pypetconstants.LOAD_DATA,
load_derived_parameters=pypetconstants.LOAD_SKELETON,
load_results=pypetconstants.LOAD_SKELETON,
load_other_data=pypetconstants.LOAD_SKELETON,
recursive=True,
... |
Checks if two trajectories live in the same space and can be merged. | def _check_if_both_have_same_parameters(self, other_trajectory,
ignore_data, consecutive_merge):
""" Checks if two trajectories live in the same space and can be merged. """
if not isinstance(other_trajectory, Trajectory):
raise TypeError('Can onl... |
Backs up the trajectory with the given storage service. | def f_backup(self, **kwargs):
"""Backs up the trajectory with the given storage service.
Arguments of ``kwargs`` are directly passed to the storage service,
for the HDF5StorageService you can provide the following argument:
:param backup_filename:
Name of file where to sto... |
Creates a full mapping from all wildcard translations to the corresponding wildcards | def _make_reversed_wildcards(self, old_length=-1):
"""Creates a full mapping from all wildcard translations to the corresponding wildcards"""
if len(self._reversed_wildcards) > 0:
# We already created reversed wildcards, so we don't need to do all of them
# again
star... |
Can be used to merge several other_trajectories into your current one. | def f_merge_many(self, other_trajectories,
ignore_data=(),
move_data=False,
delete_other_trajectory=False,
keep_info=True,
keep_other_trajectory_info=True,
merge_config=True,
backup=True):
"""Can be u... |
Merges another trajectory into the current trajectory. | def f_merge(self, other_trajectory, trial_parameter=None, remove_duplicates=False,
ignore_data=(),
backup=True,
move_data=False,
delete_other_trajectory=False,
keep_info=True,
keep_other_trajectory_info=True,
... |
Updates the run_information of the current trajectory. | def _merge_single_runs(self, other_trajectory, used_runs):
""" Updates the `run_information` of the current trajectory."""
count = len(self) # Variable to count the increasing new run indices and create
# new run names
run_indices = range(len(other_trajectory))
run_name_dict ... |
Renames a full name based on the wildcards and a particular run | def _rename_full_name(self, full_name, other_trajectory, used_runs=None, new_run_idx=None):
"""Renames a full name based on the wildcards and a particular run"""
split_name = full_name.split('.')
for idx, name in enumerate(split_name):
if name in other_trajectory._reversed_wildcards:... |
Merges derived parameters that have the run_ALL in a name. | def _merge_derived_parameters(self,
other_trajectory,
used_runs,
rename_dict,
allowed_translations,
ignore_data):
""" Merges derived... |
Merges all links | def _merge_links(self, other_trajectory, used_runs, allowed_translations, ignore_data):
""" Merges all links"""
linked_items = other_trajectory._linked_by
run_name_dummys = set([f(-1) for f in other_trajectory._wildcard_functions.values()])
if len(linked_items) > 0:
self._log... |
Merges meta data about previous merges git commits and environment settings of the other trajectory into the current one. | def _merge_config(self, other_trajectory):
"""Merges meta data about previous merges, git commits, and environment settings
of the other trajectory into the current one.
"""
self._logger.info('Merging config!')
# Merge git commit meta data
if 'config.git' in other_traje... |
Merges trajectories by loading iteratively items of the other trajectory and store it into the current trajectory. | def _merge_slowly(self, other_trajectory, rename_dict):
"""Merges trajectories by loading iteratively items of the other trajectory and
store it into the current trajectory.
:param rename_dict:
Dictionary containing mappings from the old result names in the `other_trajectory`
... |
Merges all results. | def _merge_results(self, other_trajectory, rename_dict, used_runs, allowed_translations,
ignore_data):
"""Merges all results.
:param rename_dict:
Dictionary that is filled with the names of results in the `other_trajectory`
as keys and the corresponding n... |
Merges parameters from the other trajectory into the current one. | def _merge_parameters(self, other_trajectory, remove_duplicates=False,
trial_parameter_name=None,
ignore_data=()):
"""Merges parameters from the other trajectory into the current one.
The explored parameters in the current trajectory are directly enla... |
Can be called to rename and relocate the trajectory. | def f_migrate(self, new_name=None, in_store=False,
new_storage_service=None, **kwargs):
"""Can be called to rename and relocate the trajectory.
:param new_name: New name of the trajectory, None if you do not want to change the name.
:param in_store:
Set this to T... |
Stores the trajectory to disk and recursively all data in the tree. | def f_store(self, only_init=False, store_data=pypetconstants.STORE_DATA,
max_depth=None):
""" Stores the trajectory to disk and recursively all data in the tree.
:param only_init:
If you just want to initialise the store. If yes, only meta information about
the ... |
Whether no results nor parameters have been added yet to the trajectory ( ignores config ). | def f_is_empty(self):
""" Whether no results nor parameters have been added yet to the trajectory
(ignores config)."""
return (len(self._parameters) == 0 and
len(self._derived_parameters) == 0 and
len(self._results) == 0 and
len(self._other_leaves)... |
Restores the default value in all explored parameters and sets the v_idx property back to - 1 and v_crun to None. | def f_restore_default(self):
""" Restores the default value in all explored parameters and sets the
v_idx property back to -1 and v_crun to None."""
self._idx = -1
self._crun = None
for param in self._explored_parameters.values():
if param is not None:
... |
Notifies the explored parameters what current point in the parameter space they should represent. | def _set_explored_parameters_to_idx(self, idx):
""" Notifies the explored parameters what current point in the parameter space
they should represent.
"""
for param in self._explored_parameters.values():
if param is not None:
param._set_parameter_access(idx) |
Modifies the trajectory for single runs executed by the environment | def _make_single_run(self):
""" Modifies the trajectory for single runs executed by the environment """
self._is_run = False # to be able to use f_set_crun
self._new_nodes = OrderedDict()
self._new_links = OrderedDict()
self._is_run = True
return self |
Returns a list of run names. | def f_get_run_names(self, sort=True):
""" Returns a list of run names.
ONLY useful for a single run during multiprocessing if ``v_full_copy` was set to ``True``.
Otherwise only the current run is available.
:param sort:
Whether to get them sorted, will only require O(N) [a... |
Returns a dictionary containing information about a single run. | def f_get_run_information(self, name_or_idx=None, copy=True):
""" Returns a dictionary containing information about a single run.
ONLY useful during a single run if ``v_full_copy` was set to ``True``.
Otherwise only the current run is available.
The information dictionaries have the fo... |
Finds a single run index given a particular condition on parameters. | def f_find_idx(self, name_list, predicate):
""" Finds a single run index given a particular condition on parameters.
ONLY useful for a single run if ``v_full_copy` was set to ``True``.
Otherwise a TypeError is thrown.
:param name_list:
A list of parameter names the predica... |
Can be used to manually allow running of an experiment without using an environment. | def f_start_run(self, run_name_or_idx=None, turn_into_run=True):
""" Can be used to manually allow running of an experiment without using an environment.
:param run_name_or_idx:
Can manually set a trajectory to a particular run. If `None` the current run
the trajectory is set t... |
Can be called to finish a run if manually started. | def f_finalize_run(self, store_meta_data=True, clean_up=True):
""" Can be called to finish a run if manually started.
Does NOT reset the index of the run,
i.e. ``f_restore_default`` should be called manually if desired.
Does NOT store any data (except meta data) so you have to call
... |
Sets the start timestamp and formatted time to the current time. | def _set_start(self):
""" Sets the start timestamp and formatted time to the current time. """
init_time = time.time()
formatted_time = datetime.datetime.fromtimestamp(init_time).strftime('%Y_%m_%d_%Hh%Mm%Ss')
run_info_dict = self._run_information[self.v_crun]
run_info_dict['time... |
Summarizes the parameter settings. | def _summarize_explored_parameters(self):
"""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 group with the ... |
Sets the finish time and computes the runtime in human readable format | def _set_finish(self):
""" Sets the finish time and computes the runtime in human readable format """
run_info_dict = self._run_information[self.v_crun]
timestamp_run = run_info_dict['timestamp']
run_summary = self._summarize_explored_parameters()
finish_timestamp_run = time.t... |
Creates a new node. Checks if the new node needs to know the trajectory. | def _construct_instance(self, constructor, full_name, *args, **kwargs):
""" Creates a new node. Checks if the new node needs to know the trajectory.
:param constructor: The constructor to use
:param full_name: Full name of node
:param args: Arguments passed to constructor
:para... |
Returns a dictionary containing either all parameters all explored parameters all config all derived parameters or all results. | def _return_item_dictionary(param_dict, fast_access, copy):
"""Returns a dictionary containing either all parameters, all explored parameters,
all config, all derived parameters, or all results.
:param param_dict: The dictionary which is about to be returned
:param fast_access: Whether ... |
Called by the environment after storing to perform some rollback operations. | def _finalize_run(self):
"""Called by the environment after storing to perform some rollback operations.
All results and derived parameters created in the current run are removed.
Important for single processing to not blow up the parent trajectory with the results
of all runs.
... |
Returns a dictionary with pairings of ( full ) names as keys and instances/ values. | def f_to_dict(self, fast_access=False, short_names=False, nested=False,
copy=True, with_links=True):
"""Returns a dictionary with pairings of (full) names as keys and instances/values.
:param fast_access:
If True, parameter values are returned instead of the instances.
... |
Returns a dictionary containing the full config names as keys and the config parameters or the config parameter data items as values. | def f_get_config(self, fast_access=False, copy=True):
"""Returns a dictionary containing the full config names as keys and the config parameters
or the config parameter data items as values.
:param fast_access:
Determines whether the parameter objects or their values are returned
... |
Returns a dictionary containing the full parameter names as keys and the parameters or the parameter data items as values. | def f_get_parameters(self, fast_access=False, copy=True):
""" Returns a dictionary containing the full parameter names as keys and the parameters
or the parameter data items as values.
:param fast_access:
Determines whether the parameter objects or their values are returned
... |
Returns a dictionary containing the full parameter names as keys and the parameters or the parameter data items as values. | def f_get_explored_parameters(self, fast_access=False, copy=True):
""" Returns a dictionary containing the full parameter names as keys and the parameters
or the parameter data items as values.
IMPORTANT: This dictionary always contains all explored parameters as keys.
Even when they... |
Returns a dictionary containing the full parameter names as keys and the parameters or the parameter data items as values. | def f_get_derived_parameters(self, fast_access=False, copy=True):
""" Returns a dictionary containing the full parameter names as keys and the parameters
or the parameter data items as values.
:param fast_access:
Determines whether the parameter objects or their values are return... |
Returns a dictionary containing the full result names as keys and the corresponding result objects or result data items as values. | def f_get_results(self, fast_access=False, copy=True):
""" Returns a dictionary containing the full result names as keys and the corresponding
result objects or result data items as values.
:param fast_access:
Determines whether the result objects or their values are returned
... |
Stores a single item see also: func: ~pypet. trajectory. Trajectory. f_store_items. | def f_store_item(self, item, *args, **kwargs):
"""Stores a single item, see also :func:`~pypet.trajectory.Trajectory.f_store_items`."""
self.f_store_items([item], *args, **kwargs) |
Stores individual items to disk. | def f_store_items(self, iterator, *args, **kwargs):
"""Stores individual items to disk.
This function is useful if you calculated very large results (or large derived parameters)
during runtime and you want to write these to disk immediately and empty them afterwards
to free some memory... |
Loads a single item see also: func: ~pypet. trajectory. Trajectory. f_load_items | def f_load_item(self, item, *args, **kwargs):
"""Loads a single item, see also :func:`~pypet.trajectory.Trajectory.f_load_items`"""
self.f_load_items([item], *args, **kwargs) |
Loads parameters and results specified in iterator. | def f_load_items(self, iterator, *args, **kwargs):
"""Loads parameters and results specified in `iterator`.
You can directly list the Parameter objects or just their names.
If names are given the `~pypet.naturalnaming.NNGroupNode.f_get` method is applied to find the
parameters or resul... |
Removes a single item see: func: ~pypet. trajectory. Trajectory. f_remove_items | def f_remove_item(self, item, recursive=False):
"""Removes a single item, see :func:`~pypet.trajectory.Trajectory.f_remove_items`"""
self.f_remove_items([item], recursive=recursive) |
Removes parameters results or groups from the trajectory. | def f_remove_items(self, iterator, recursive=False):
"""Removes parameters, results or groups from the trajectory.
This function ONLY removes items from your current trajectory and does not delete
data stored to disk. If you want to delete data from disk, take a look at
:func:`~pypet.tr... |
Deletes several links from the hard disk. | def f_delete_links(self, iterator_of_links, remove_from_trajectory=False):
"""Deletes several links from the hard disk.
Links can be passed as a string ``'groupA.groupB.linkA'``
or as a tuple containing the node from which the link should be removed and the
name of the link ``(groupWit... |
Recursively removes all children of the trajectory | def f_remove(self, recursive=True, predicate=None):
"""Recursively removes all children of the trajectory
:param recursive:
Only here for consistency with signature of parent method. Cannot be set
to `False` because the trajectory root node cannot be removed.
:param pr... |
Deletes a single item see: func: ~pypet. trajectory. Trajectory. f_delete_items | def f_delete_item(self, item, *args, **kwargs):
"""Deletes a single item, see :func:`~pypet.trajectory.Trajectory.f_delete_items`"""
self.f_delete_items([item], *args, **kwargs) |
Deletes items from storage on disk. | def f_delete_items(self, iterator, *args, **kwargs):
"""Deletes items from storage on disk.
Per default the item is NOT removed from the trajectory.
Links are NOT deleted on the hard disk, please delete links manually before deleting
data!
:param iterator:
A seque... |
Starts a pool single run and passes the storage service | def _pool_single_run(kwargs):
"""Starts a pool single run and passes the storage service"""
wrap_mode = kwargs['wrap_mode']
traj = kwargs['traj']
traj.v_storage_service = _pool_single_run.storage_service
if wrap_mode == pypetconstants.WRAP_MODE_LOCAL:
# Free references from previous runs
... |
Single run wrapper for the frozen pool makes a single run and passes kwargs | def _frozen_pool_single_run(kwargs):
"""Single run wrapper for the frozen pool, makes a single run and passes kwargs"""
idx = kwargs.pop('idx')
frozen_kwargs = _frozen_pool_single_run.kwargs
frozen_kwargs.update(kwargs) # in case of `run_map`
# we need to update job's args and kwargs
traj = fro... |
Configures the pool and keeps the storage service | def _configure_pool(kwargs):
"""Configures the pool and keeps the storage service"""
_pool_single_run.storage_service = kwargs['storage_service']
_configure_niceness(kwargs)
_configure_logging(kwargs, extract=False) |
Configures the frozen pool and keeps all kwargs | def _configure_frozen_pool(kwargs):
"""Configures the frozen pool and keeps all kwargs"""
_frozen_pool_single_run.kwargs = kwargs
_configure_niceness(kwargs)
_configure_logging(kwargs, extract=False)
# Reset full copy to it's old value
traj = kwargs['traj']
traj.v_full_copy = kwargs['full_co... |
Wrapper function that first configures logging and starts a single run afterwards. | def _process_single_run(kwargs):
"""Wrapper function that first configures logging and starts a single run afterwards."""
_configure_niceness(kwargs)
_configure_logging(kwargs)
result_queue = kwargs['result_queue']
result = _sigint_handling_single_run(kwargs)
result_queue.put(result)
result_... |
Wrapper function that configures a frozen SCOOP set up. | def _configure_frozen_scoop(kwargs):
"""Wrapper function that configures a frozen SCOOP set up.
Deletes of data if necessary.
"""
def _delete_old_scoop_rev_data(old_scoop_rev):
if old_scoop_rev is not None:
try:
elements = shared.elements
for key in ... |
Wrapper function for scoop that does not configure logging | def _scoop_single_run(kwargs):
"""Wrapper function for scoop, that does not configure logging"""
try:
try:
is_origin = scoop.IS_ORIGIN
except AttributeError:
# scoop is not properly started, i.e. with `python -m scoop...`
# in this case scoop uses default `map... |
Requests the logging manager to configure logging. | def _configure_logging(kwargs, extract=True):
"""Requests the logging manager to configure logging.
:param extract:
If naming data should be extracted from the trajectory
"""
try:
logging_manager = kwargs['logging_manager']
if extract:
logging_manager.extract_repla... |
Sets niceness of a process | def _configure_niceness(kwargs):
"""Sets niceness of a process"""
niceness = kwargs['niceness']
if niceness is not None:
try:
try:
current = os.nice(0)
if niceness - current > 0:
# Under Linux you cannot decrement niceness if set elsewh... |
Wrapper that allow graceful exits of single runs | def _sigint_handling_single_run(kwargs):
"""Wrapper that allow graceful exits of single runs"""
try:
graceful_exit = kwargs['graceful_exit']
if graceful_exit:
sigint_handling.start()
if sigint_handling.hit:
result = (sigint_handling.SIGINT, None)
... |
Performs a single run of the experiment. | def _single_run(kwargs):
""" 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 *arg... |
Starts running a queue handler and creates a log file for the queue. | def _wrap_handling(kwargs):
""" Starts running a queue handler and creates a log file for the queue."""
_configure_logging(kwargs, extract=False)
# Main job, make the listener to the queue start receiving message for writing to disk.
handler=kwargs['handler']
graceful_exit = kwargs['graceful_exit']
... |
Loads a class from a string naming the module and class name. | def load_class(full_class_string):
"""Loads a class from a string naming the module and class name.
For example:
>>> load_class(full_class_string = 'pypet.brian.parameter.BrianParameter')
<BrianParameter>
"""
class_data = full_class_string.split(".")
module_path = ".".join(class_data[:-1]... |
Dynamically creates a class. | def create_class(class_name, dynamic_imports):
"""Dynamically creates a class.
It is tried if the class can be created by the already given imports.
If not the list of the dynamically loaded classes is used.
"""
try:
new_class = globals()[class_name]
if not inspect.isclass(new_cla... |
Returns the length of the parameter range. | def f_get_range_length(self):
"""Returns the length of the parameter range.
Raises TypeError if the parameter has no range.
Does not need to be implemented if the parameter supports
``__len__`` appropriately.
"""
if not self.f_has_range():
raise TypeError('... |
String summary of the value handled by the parameter. | def f_val_to_str(self):
"""String summary of the value handled by the parameter.
Note that representing the parameter as a string accesses its value,
but for simpler debugging, this does not lock the parameter or counts as usage!
Calls `__repr__` of the contained value.
"""
... |
Checks if the parameter considers two values as equal. | def _equal_values(self, val1, val2):
"""Checks if the parameter considers two values as equal.
This is important for the trajectory in case of merging. In case you want to delete
duplicate parameter points, the trajectory needs to know when two parameters
are equal. Since equality is no... |
Checks if two values agree in type. | def _values_of_same_type(self, val1, val2):
"""Checks if two values agree in type.
For example, two 32 bit integers would be of same type, but not a string and an integer,
nor a 64 bit and a 32 bit integer.
This is important for exploration. You are only allowed to explore data that
... |
Checks if input data is supported by the parameter. | def f_supports(self, data):
"""Checks if input data is supported by the parameter."""
dtype = type(data)
if dtype is tuple or dtype is list:
# Parameters cannot handle empty tuples
if len(data) == 0:
return False
old_type = None
... |
Checks if two values agree in type. | def _values_of_same_type(self, val1, val2):
"""Checks if two values agree in type.
Raises a TypeError if both values are not supported by the parameter.
Returns false if only one of the two values is supported by the parameter.
Example usage:
>>>param._values_of_same_type(42,4... |
Returns a python iterable containing the exploration range. | def f_get_range(self, copy=True):
"""Returns a python iterable containing the exploration range.
:param copy:
If the range should be copied before handed over to avoid tempering with data
Example usage:
>>> param = Parameter('groupA.groupB.myparam',data=22, comment='I am ... |
Explores the parameter according to the iterable. | def _explore(self, explore_iterable):
"""Explores the parameter according to the iterable.
Raises ParameterLockedException if the parameter is locked.
Raises TypeError if the parameter does not support the data,
the types of the data in the iterable are not the same as the type of the d... |
Explores the parameter according to the iterable and appends to the exploration range. | def _expand(self, explore_iterable):
"""Explores the parameter according to the iterable and appends to the exploration range.
Raises ParameterLockedException if the parameter is locked.
Raises TypeError if the parameter does not support the data,
the types of the data in the iterable a... |
Checks if data values are valid. | def _data_sanity_checks(self, explore_iterable):
"""Checks if data values are valid.
Checks if the data values are supported by the parameter and if the values are of the same
type as the default value.
"""
data_list = []
for val in explore_iterable:
if n... |
Returns a dictionary of formatted data understood by the storage service. | def _store(self):
"""Returns a dictionary of formatted data understood by the storage service.
The data is put into an :class:`~pypet.parameter.ObjectTable` named 'data'.
If the parameter is explored, the exploration range is also put into another table
named 'explored_data'.
:... |
Loads the data and exploration range from the load_dict. | def _load(self, load_dict):
"""Loads the data and exploration range from the `load_dict`.
The `load_dict` needs to be in the same format as the result of the
:func:`~pypet.parameter.Parameter._store` method.
"""
if self.v_locked:
raise pex.ParameterLockedException('... |
Creates a storage dictionary for the storage service. | def _store(self):
"""Creates a storage dictionary for the storage service.
If the data is not a numpy array, a numpy matrix, or a tuple, the
:func:`~pypet.parameter.Parmater._store` method of the parent class is called.
Otherwise the array is put into the dictionary with the key 'data_... |
Reconstructs the data and exploration array. | def _load(self, load_dict):
"""Reconstructs the data and exploration array.
Checks if it can find the array identifier in the `load_dict`, i.e. '__rr__'.
If not calls :class:`~pypet.parameter.Parameter._load` of the parent class.
If the parameter is explored, the exploration range of a... |
Checks if two values agree in type. | def _values_of_same_type(self, val1, val2):
"""Checks if two values agree in type.
The array parameter is less restrictive than the parameter. If both values
are arrays, matrices or tuples, they are considered to be of same type
regardless of their size and values they contain.
... |
Checks if input data is supported by the parameter. | def f_supports(self, data):
"""Checks if input data is supported by the parameter."""
dtype = type(data)
if dtype is tuple or dtype is list and len(data) == 0:
return True # ArrayParameter does support empty tuples
elif dtype is np.ndarray and data.size == 0 and data.ndim =... |
Checks if two values agree in type. | def _values_of_same_type(self, val1, val2):
"""Checks if two values agree in type.
The sparse parameter is less restrictive than the parameter. If both values
are sparse matrices they are considered to be of same type
regardless of their size and values they contain.
"""
... |
Matrices are equal if they hash to the same value. | def _equal_values(self, val1, val2):
"""Matrices are equal if they hash to the same value."""
if self._is_supported_matrix(val1):
if self._is_supported_matrix(val2):
_, _, hash_tuple_1 = self._serialize_matrix(val1)
_, _, hash_tuple_2 = self._serialize_matrix... |
Checks if a data is csr csc bsr or dia Scipy sparse matrix | def _is_supported_matrix(data):
"""Checks if a data is csr, csc, bsr, or dia Scipy sparse matrix"""
return (spsp.isspmatrix_csc(data) or
spsp.isspmatrix_csr(data) or
spsp.isspmatrix_bsr(data) or
spsp.isspmatrix_dia(data)) |
Sparse matrices support Scipy csr csc bsr and dia matrices and everything their parent class the: class: ~pypet. parameter. ArrayParameter supports. | def f_supports(self, data):
"""Sparse matrices support Scipy csr, csc, bsr and dia matrices and everything their parent
class the :class:`~pypet.parameter.ArrayParameter` supports.
"""
if self._is_supported_matrix(data):
return True
else:
return super(Spa... |
Extracts data from a sparse matrix to make it serializable in a human readable format. | def _serialize_matrix(matrix):
"""Extracts data from a sparse matrix to make it serializable in a human readable format.
:return: Tuple with following elements:
1.
A list containing data that is necessary to reconstruct the matrix.
For csr, csc, and bsr mat... |
Creates a storage dictionary for the storage service. | def _store(self):
"""Creates a storage dictionary for the storage service.
If the data is not a supported sparse matrix, the
:func:`~pypet.parameter.ArrayParmater._store` method of the parent class is called.
Otherwise the matrix is split into parts with
:func:`~pypet.parameter... |
Formats a name for storage | def _build_names(self, name_idx, is_dia):
"""Formats a name for storage
:return: A tuple of names with the following format:
`xspm__spsp__XXXX__spsp__XXXXXXXX` where the first 'XXXX' refer to the property and
the latter 'XXXXXXX' to the sparse matrix index.
"""
... |
Reconstructs a matrix from a list containing sparse matrix extracted properties | def _reconstruct_matrix(data_list):
"""Reconstructs a matrix from a list containing sparse matrix extracted properties
`data_list` needs to be formatted as the first result of
:func:`~pypet.parameter.SparseParameter._serialize_matrix`
"""
matrix_format = data_list[0]
da... |
Reconstructs the data and exploration array | def _load(self, load_dict):
"""Reconstructs the data and exploration array
Checks if it can find the array identifier in the `load_dict`, i.e. '__spsp__'.
If not, calls :class:`~pypet.parameter.ArrayParameter._load` of the parent class.
If the parameter is explored, the exploration ran... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.