_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q274200 | Trajectory._remove_exploration | test | 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:
... | python | {
"resource": ""
} |
q274201 | Trajectory._copy_from | test | 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... | python | {
"resource": ""
} |
q274202 | Trajectory.f_explore | test | 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... | python | {
"resource": ""
} |
q274203 | Trajectory._update_run_information | test | 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) | python | {
"resource": ""
} |
q274204 | Trajectory._add_run_info | test | 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... | python | {
"resource": ""
} |
q274205 | Trajectory.f_lock_parameters | test | 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() | python | {
"resource": ""
} |
q274206 | Trajectory.f_lock_derived_parameters | test | 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() | python | {
"resource": ""
} |
q274207 | Trajectory._finalize | test | 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.
... | python | {
"resource": ""
} |
q274208 | Trajectory.f_load_skeleton | test | 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... | python | {
"resource": ""
} |
q274209 | Trajectory.f_load | test | 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,
... | python | {
"resource": ""
} |
q274210 | Trajectory.f_backup | test | 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... | python | {
"resource": ""
} |
q274211 | Trajectory._make_reversed_wildcards | test | 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... | python | {
"resource": ""
} |
q274212 | Trajectory.f_merge_many | test | 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... | python | {
"resource": ""
} |
q274213 | Trajectory._merge_single_runs | test | 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 ... | python | {
"resource": ""
} |
q274214 | Trajectory._rename_full_name | test | 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:... | python | {
"resource": ""
} |
q274215 | Trajectory._merge_derived_parameters | test | def _merge_derived_parameters(self,
other_trajectory,
used_runs,
rename_dict,
allowed_translations,
ignore_data):
""" Merges derived... | python | {
"resource": ""
} |
q274216 | Trajectory._merge_links | test | 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... | python | {
"resource": ""
} |
q274217 | Trajectory._merge_config | test | 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... | python | {
"resource": ""
} |
q274218 | Trajectory._merge_slowly | test | 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`
... | python | {
"resource": ""
} |
q274219 | Trajectory._merge_results | test | 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... | python | {
"resource": ""
} |
q274220 | Trajectory.f_migrate | test | 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... | python | {
"resource": ""
} |
q274221 | Trajectory.f_store | test | 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 ... | python | {
"resource": ""
} |
q274222 | Trajectory.f_restore_default | test | 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:
... | python | {
"resource": ""
} |
q274223 | Trajectory._set_explored_parameters_to_idx | test | 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) | python | {
"resource": ""
} |
q274224 | Trajectory._make_single_run | test | 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 | python | {
"resource": ""
} |
q274225 | Trajectory.f_get_run_names | test | 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... | python | {
"resource": ""
} |
q274226 | Trajectory.f_get_run_information | test | 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... | python | {
"resource": ""
} |
q274227 | Trajectory.f_find_idx | test | 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... | python | {
"resource": ""
} |
q274228 | Trajectory.f_start_run | test | 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... | python | {
"resource": ""
} |
q274229 | Trajectory.f_finalize_run | test | 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
... | python | {
"resource": ""
} |
q274230 | Trajectory._set_start | test | 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... | python | {
"resource": ""
} |
q274231 | Trajectory._set_finish | test | 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... | python | {
"resource": ""
} |
q274232 | Trajectory._construct_instance | test | 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... | python | {
"resource": ""
} |
q274233 | Trajectory._return_item_dictionary | test | 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 ... | python | {
"resource": ""
} |
q274234 | Trajectory._finalize_run | test | 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.
... | python | {
"resource": ""
} |
q274235 | Trajectory.f_get_config | test | 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
... | python | {
"resource": ""
} |
q274236 | Trajectory.f_get_results | test | 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
... | python | {
"resource": ""
} |
q274237 | Trajectory.f_store_items | test | 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... | python | {
"resource": ""
} |
q274238 | Trajectory.f_load_items | test | 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... | python | {
"resource": ""
} |
q274239 | Trajectory.f_remove_items | test | 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... | python | {
"resource": ""
} |
q274240 | Trajectory.f_delete_links | test | 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... | python | {
"resource": ""
} |
q274241 | Trajectory.f_remove | test | 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... | python | {
"resource": ""
} |
q274242 | Trajectory.f_delete_items | test | 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... | python | {
"resource": ""
} |
q274243 | _pool_single_run | test | 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
... | python | {
"resource": ""
} |
q274244 | _frozen_pool_single_run | test | 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... | python | {
"resource": ""
} |
q274245 | _configure_pool | test | 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) | python | {
"resource": ""
} |
q274246 | _configure_frozen_pool | test | 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... | python | {
"resource": ""
} |
q274247 | _process_single_run | test | 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_... | python | {
"resource": ""
} |
q274248 | _configure_frozen_scoop | test | 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 ... | python | {
"resource": ""
} |
q274249 | _scoop_single_run | test | 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... | python | {
"resource": ""
} |
q274250 | _configure_logging | test | 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... | python | {
"resource": ""
} |
q274251 | _configure_niceness | test | 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... | python | {
"resource": ""
} |
q274252 | _sigint_handling_single_run | test | 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)
... | python | {
"resource": ""
} |
q274253 | _single_run | test | 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... | python | {
"resource": ""
} |
q274254 | _wrap_handling | test | 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']
... | python | {
"resource": ""
} |
q274255 | load_class | test | 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]... | python | {
"resource": ""
} |
q274256 | create_class | test | 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... | python | {
"resource": ""
} |
q274257 | BaseParameter.f_get_range_length | test | 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('... | python | {
"resource": ""
} |
q274258 | BaseParameter.f_val_to_str | test | 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.
"""
... | python | {
"resource": ""
} |
q274259 | BaseParameter._equal_values | test | 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... | python | {
"resource": ""
} |
q274260 | Parameter.f_get_range | test | 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 ... | python | {
"resource": ""
} |
q274261 | Parameter._explore | test | 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... | python | {
"resource": ""
} |
q274262 | Parameter._expand | test | 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... | python | {
"resource": ""
} |
q274263 | Parameter._data_sanity_checks | test | 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... | python | {
"resource": ""
} |
q274264 | Parameter._store | test | 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'.
:... | python | {
"resource": ""
} |
q274265 | Parameter._load | test | 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('... | python | {
"resource": ""
} |
q274266 | ArrayParameter._load | test | 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... | python | {
"resource": ""
} |
q274267 | SparseParameter._equal_values | test | 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... | python | {
"resource": ""
} |
q274268 | SparseParameter._is_supported_matrix | test | 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)) | python | {
"resource": ""
} |
q274269 | SparseParameter._serialize_matrix | test | 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... | python | {
"resource": ""
} |
q274270 | SparseParameter._build_names | test | 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.
"""
... | python | {
"resource": ""
} |
q274271 | SparseParameter._reconstruct_matrix | test | 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... | python | {
"resource": ""
} |
q274272 | SparseParameter._load | test | 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... | python | {
"resource": ""
} |
q274273 | PickleParameter._store | test | def _store(self):
"""Returns a dictionary for storage.
Every element in the dictionary except for 'explored_data' is a pickle dump.
Reusage of objects is identified over the object id, i.e. python's built-in id function.
'explored_data' contains the references to the objects to be abl... | python | {
"resource": ""
} |
q274274 | PickleParameter._load | test | def _load(self, load_dict):
"""Reconstructs objects from the pickle dumps in `load_dict`.
The 'explored_data' entry in `load_dict` is used to reconstruct
the exploration range in the correct order.
Sets the `v_protocol` property to the protocol used to store 'data'.
"""
... | python | {
"resource": ""
} |
q274275 | Result.f_translate_key | test | def f_translate_key(self, key):
"""Translates integer indices into the appropriate names"""
if isinstance(key, int):
if key == 0:
key = self.v_name
else:
key = self.v_name + '_%d' % key
return key | python | {
"resource": ""
} |
q274276 | Result.f_val_to_str | test | def f_val_to_str(self):
"""Summarizes data handled by the result as a string.
Calls `__repr__` on all handled data. Data is NOT ordered.
Truncates the string if it is longer than
:const:`pypetconstants.HDF5_STRCOL_MAX_VALUE_LENGTH`
:return: string
"""
resstrl... | python | {
"resource": ""
} |
q274277 | Result.f_to_dict | test | def f_to_dict(self, copy=True):
"""Returns all handled data as a dictionary.
:param copy:
Whether the original dictionary or a shallow copy is returned.
:return: Data dictionary
"""
if copy:
return self._data.copy()
else:
return sel... | python | {
"resource": ""
} |
q274278 | Result.f_set | test | def f_set(self, *args, **kwargs):
""" Method to put data into the result.
:param args:
The first positional argument is stored with the name of the result.
Following arguments are stored with `name_X` where `X` is the position
of the argument.
:param kwargs... | python | {
"resource": ""
} |
q274279 | Result.f_get | test | def f_get(self, *args):
"""Returns items handled by the result.
If only a single name is given, a single data item is returned. If several names are
given, a list is returned. For integer inputs the result returns `resultname_X`.
If the result contains only a single entry you can ca... | python | {
"resource": ""
} |
q274280 | Result.f_set_single | test | def f_set_single(self, name, item):
"""Sets a single data item of the result.
Raises TypeError if the type of the outer data structure is not understood.
Note that the type check is shallow. For example, if the data item is a list,
the individual list elements are NOT checked whether th... | python | {
"resource": ""
} |
q274281 | SparseResult._supports | test | def _supports(self, item):
"""Supports everything of parent class and csr, csc, bsr, and dia sparse matrices."""
if SparseParameter._is_supported_matrix(item):
return True
else:
return super(SparseResult, self)._supports(item) | python | {
"resource": ""
} |
q274282 | SparseResult._store | test | def _store(self):
"""Returns a storage dictionary understood by the storage service.
Sparse matrices are extracted similar to the :class:`~pypet.parameter.SparseParameter` and
marked with the identifier `__spsp__`.
"""
store_dict = {}
for key in self._data:
... | python | {
"resource": ""
} |
q274283 | SparseResult._load | test | def _load(self, load_dict):
"""Loads data from `load_dict`
Reconstruction of sparse matrices similar to the :class:`~pypet.parameter.SparseParameter`.
"""
for key in list(load_dict.keys()):
# We delete keys over time:
if key in load_dict:
if Spar... | python | {
"resource": ""
} |
q274284 | PickleResult.f_set_single | test | def f_set_single(self, name, item):
"""Adds a single data item to the pickle result.
Note that it is NOT checked if the item can be pickled!
"""
if self.v_stored:
self._logger.debug('You are changing an already stored result. If '
'you not... | python | {
"resource": ""
} |
q274285 | PickleResult._store | test | def _store(self):
"""Returns a dictionary containing pickle dumps"""
store_dict = {}
for key, val in self._data.items():
store_dict[key] = pickle.dumps(val, protocol=self.v_protocol)
store_dict[PickleResult.PROTOCOL] = self.v_protocol
return store_dict | python | {
"resource": ""
} |
q274286 | PickleResult._load | test | def _load(self, load_dict):
"""Reconstructs all items from the pickle dumps in `load_dict`.
Sets the `v_protocol` property to the protocol of the first reconstructed item.
"""
try:
self.v_protocol = load_dict.pop(PickleParameter.PROTOCOL)
except KeyError:
... | python | {
"resource": ""
} |
q274287 | main | test | def main():
"""Simply merge all trajectories in the working directory"""
folder = os.getcwd()
print('Merging all files')
merge_all_in_folder(folder,
delete_other_files=True, # We will only keep one trajectory
dynamic_imports=FunctionParameter,
... | python | {
"resource": ""
} |
q274288 | upload_file | test | def upload_file(filename, session):
""" Uploads a file """
print('Uploading file %s' % filename)
outfilesource = os.path.join(os.getcwd(), filename)
outfiletarget = 'sftp://' + ADDRESS + WORKING_DIR
out = saga.filesystem.File(outfilesource, session=session, flags=OVERWRITE)
out.copy(outfiletarge... | python | {
"resource": ""
} |
q274289 | download_file | test | def download_file(filename, session):
""" Downloads a file """
print('Downloading file %s' % filename)
infilesource = os.path.join('sftp://' + ADDRESS + WORKING_DIR,
filename)
infiletarget = os.path.join(os.getcwd(), filename)
incoming = saga.filesystem.File(infileso... | python | {
"resource": ""
} |
q274290 | create_session | test | def create_session():
""" Creates and returns a new SAGA session """
ctx = saga.Context("UserPass")
ctx.user_id = USER
ctx.user_pass = PASSWORD
session = saga.Session()
session.add_context(ctx)
return session | python | {
"resource": ""
} |
q274291 | merge_trajectories | test | def merge_trajectories(session):
""" Merges all trajectories found in the working directory """
jd = saga.job.Description()
jd.executable = 'python'
jd.arguments = ['merge_trajs.py']
jd.output = "mysagajob_merge.stdout"
jd.error = "mysagajob_merge.stderr"
jd.wo... | python | {
"resource": ""
} |
q274292 | start_jobs | test | def start_jobs(session):
""" Starts all jobs and runs `the_task.py` in batches. """
js = saga.job.Service('ssh://' + ADDRESS, session=session)
batches = range(3)
jobs = []
for batch in batches:
print('Starting batch %d' % batch)
jd = saga.job.Description()
jd.executable ... | python | {
"resource": ""
} |
q274293 | multiply | test | def multiply(traj):
"""Sophisticated simulation of multiplication"""
z=traj.x*traj.y
traj.f_add_result('z',z=z, comment='I am the product of two reals!') | python | {
"resource": ""
} |
q274294 | run_neuron | test | def run_neuron(traj):
"""Runs a simulation of a model neuron.
:param traj:
Container with all parameters.
:return:
An estimate of the firing rate of the neuron
"""
# Extract all parameters from `traj`
V_init = traj.par.neuron.V_init
I = traj.par.neuron.I
tau_V = tra... | python | {
"resource": ""
} |
q274295 | neuron_postproc | test | def neuron_postproc(traj, result_list):
"""Postprocessing, sorts computed firing rates into a table
:param traj:
Container for results and parameters
:param result_list:
List of tuples, where first entry is the run index and second is the actual
result of the corresponding run.
... | python | {
"resource": ""
} |
q274296 | add_parameters | test | def add_parameters(traj):
"""Adds all parameters to `traj`"""
print('Adding Parameters')
traj.f_add_parameter('neuron.V_init', 0.0,
comment='The initial condition for the '
'membrane potential')
traj.f_add_parameter('neuron.I', 0.0,
... | python | {
"resource": ""
} |
q274297 | add_exploration | test | def add_exploration(traj):
"""Explores different values of `I` and `tau_ref`."""
print('Adding exploration of I and tau_ref')
explore_dict = {'neuron.I': np.arange(0, 1.01, 0.01).tolist(),
'neuron.tau_ref': [5.0, 7.5, 10.0]}
explore_dict = cartesian_product(explore_dict, ('neuron.... | python | {
"resource": ""
} |
q274298 | NetworkRunner.execute_network_pre_run | test | def execute_network_pre_run(self, traj, network, network_dict, component_list, analyser_list):
"""Runs a network before the actual experiment.
Called by a :class:`~pypet.brian2.network.NetworkManager`.
Similar to :func:`~pypet.brian2.network.NetworkRunner.run_network`.
Subruns and thei... | python | {
"resource": ""
} |
q274299 | NetworkRunner.execute_network_run | test | def execute_network_run(self, traj, network, network_dict, component_list, analyser_list):
"""Runs a network in an experimental run.
Called by a :class:`~pypet.brian2.network.NetworkManager`.
A network run is divided into several subruns which are defined as
:class:`~pypet.brian2.param... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.