return self._no_clobber<EOL>

If `f_add_leaf` should not throw an error in case something is added
        that is already part of the Trajectory. If `True` no error is thrown and
        the new data is ignored.


self._no_clobber = bool(value)<EOL>


return self._auto_run_prepend<EOL>

If during run the `runs.run_XXXXXXXX` should be prepended if it is missing.

        Is not considered for `f_add_leaf` and `f_add_group` which never prepend.


self._auto_run_prepend = bool(value)<EOL>


return self._fast_access<EOL>

Whether parameter instances (False) or their values (True) are returned via natural
        naming.

        Works also for results if they contain a single item with the name of the result.

        Default is True.


self._fast_access = bool(value)<EOL>


return self._environment_hexsha<EOL>

If the trajectory is used with an environment this returns
        the SHA-1 code of the environment.


return self._environment_name<EOL>

If the trajectory is used with an environment this returns
        the name of the environment.


@staticmethod<EOL><INDENT>def _return_item_dictionary(param_dict, fast_access, copy):<DEDENT>

if not copy and fast_access:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not fast_access:<EOL><INDENT>if copy:<EOL><INDENT>return param_dict.copy()<EOL><DEDENT>else:<EOL><INDENT>return param_dict<EOL><DEDENT><DEDENT>else:<EOL><INDENT>resdict = {}<EOL>for key in param_dict:<EOL><INDENT>param = param_dict[key]<EOL>val = param.f_get()<EOL>resdict[key] = val<EOL><DEDENT>return resdict<EOL><DEDENT>

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 to use fast access
        :param copy: If the original dict should be returned or a shallow copy

        :return: The dictionary

        :raises: ValueError if `copy=False` and fast_access=True`


self._run_information[self.v_crun]['<STR_LIT>'] = <NUM_LIT:1><EOL>while len(self._new_links):<EOL><INDENT>name_pair, child_parent_pair = self._new_links.popitem(last=False)<EOL>parent_node, _ = child_parent_pair<EOL>_, link = name_pair<EOL>parent_node.f_remove_child(link)<EOL><DEDENT>while len(self._new_nodes):<EOL><INDENT>_, child_parent_pair = self._new_nodes.popitem(last=False)<EOL>parent, child = child_parent_pair<EOL>child_name = child.v_name<EOL>parent.f_remove_child(child_name, recursive=True)<EOL><DEDENT>

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.


def f_to_dict(self, fast_access=False, short_names=False, nested=False,<EOL>copy=True, with_links=True):

return self._nn_interface._to_dict(self, fast_access=fast_access,<EOL>short_names=short_names,<EOL>nested=nested,<EOL>copy=copy, with_links=with_links)<EOL>

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.
            Works also for results if they contain a single item with the name of the result.

        :param short_names:

            If true, keys are not full names but only the names. Raises a ValueError
            if the names are not unique.

        :param nested:

            If true, a nested dictionary is returned.

        :param copy:

            If `fast_access=False` and `short_names=False` you can access the original
            data dictionary if you set `copy=False`. If you do that, please do not
            modify anything! Raises ValueError if `copy=False` and `fast_access=True`
            or `short_names=True`.

        :param with_links:

            If links should be ignored

        :return: dictionary

        :raises: ValueError


def f_get_config(self, fast_access=False, copy=True):

return self._return_item_dictionary(self._config, fast_access, copy)<EOL>

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
            in the dictionary.

        :param copy:

            Whether the original dictionary or a shallow copy is returned.
            If you want the real dictionary please do not modify it at all!
            Not Copying and fast access do not work at the same time! Raises ValueError
            if fast access is true and copy false.

        :return: Dictionary containing the config data

        :raises: ValueError


def f_get_parameters(self, fast_access=False, copy=True):

return self._return_item_dictionary(self._parameters, fast_access, copy)<EOL>

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
            in the dictionary.

        :param copy:

            Whether the original dictionary or a shallow copy is returned.
            If you want the real dictionary please do not modify it at all!
            Not Copying and fast access do not work at the same time! Raises ValueError
            if fast access is true and copy false.

        :return: Dictionary containing the parameters.

        :raises: ValueError


def f_get_explored_parameters(self, fast_access=False, copy=True):

return self._return_item_dictionary(self._explored_parameters, fast_access, copy)<EOL>

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 are not loaded, in this case the value is simply `None`.
         `fast_access` only works if all explored parameters are loaded.

        :param fast_access:

            Determines whether the parameter objects or their values are returned
            in the dictionary.

        :param copy:

            Whether the original dictionary or a shallow copy is returned.
            If you want the real dictionary please do not modify it at all!
            Not Copying and fast access do not work at the same time! Raises ValueError
            if fast access is true and copy false.

        :return: Dictionary containing the parameters.

        :raises: ValueError


def f_get_derived_parameters(self, fast_access=False, copy=True):

return self._return_item_dictionary(self._derived_parameters, fast_access, copy)<EOL>


def f_get_results(self, fast_access=False, copy=True):

return self._return_item_dictionary(self._results, fast_access, copy)<EOL>

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
            in the dictionary. Works only for results if they contain a single item with
            the name of the result.

        :param copy:

            Whether the original dictionary or a shallow copy is returned.
            If you want the real dictionary please do not modify it at all!
            Not Copying and fast access do not work at the same time! Raises ValueError
            if fast access is true and copy false.

        :return: Dictionary containing the results.

        :raises: ValueError


def f_store_item(self, item, *args, **kwargs):

self.f_store_items([item], *args, **kwargs)<EOL>

Stores a single item, see also :func:`~pypet.trajectory.Trajectory.f_store_items`.


def f_store_items(self, iterator, *args, **kwargs):

if not self._stored:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>fetched_items = self._nn_interface._fetch_items(STORE, iterator, args, kwargs)<EOL>if fetched_items:<EOL><INDENT>self._storage_service.store(pypetconstants.LIST, fetched_items,<EOL>trajectory_name=self.v_name)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

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.

        Instead of storing individual parameters or results you can also store whole subtrees with
        :func:`~pypet.naturalnaming.NNGroupNode.f_store_child`.

        You can pass the following arguments to `f_store_items`:

        :param iterator:

            An iterable containing the parameters or results to store, either their
            names or the instances. You can also pass group instances or names here
            to store the annotations of the groups.

        :param non_empties:

            Optional keyword argument (boolean),
            if `True` will only store the subset of provided items that are not empty.
            Empty parameters or results found in `iterator` are simply ignored.

        :param args: Additional arguments passed to the storage service

        :param kwargs:

            If you use the standard hdf5 storage service, you can pass the following additional
            keyword argument:

            :param overwrite:

                List names of parts of your item that should
                be erased and overwritten by the new data in your leaf.
                You can also set `overwrite=True`
                to overwrite all parts.

                For instance:

                    >>> traj.f_add_result('mygroup.myresult', partA=42, partB=44, partC=46)
                    >>> traj.f_store()
                    >>> traj.mygroup.myresult.partA = 333
                    >>> traj.mygroup.myresult.partB = 'I am going to change to a string'
                    >>> traj.f_store_item('mygroup.myresult', overwrite=['partA', 'partB'])

                Will store `'mygroup.myresult'` to disk again and overwrite the parts
                `'partA'` and `'partB'` with the new values `333` and
                `'I am going to change to a string'`.
                The data stored as `partC` is not changed.

                Be aware that you need to specify the names of parts as they were stored
                to HDF5. Depending on how your leaf construction works, this may differ
                from the names the data might have in your leaf in the trajectory container.

                Note that massive overwriting will fragment and blow up your HDF5 file.
                Try to avoid changing data on disk whenever you can.

        :raises:

            TypeError:

                If the (parent) trajectory has never been stored to disk. In this case
                use :func:`pypet.trajectory.f_store` first.

            ValueError: If no item could be found to be stored.

        Note if you use the standard hdf5 storage service, there are no additional arguments
        or keyword arguments to pass!


def f_load_item(self, item, *args, **kwargs):

self.f_load_items([item], *args, **kwargs)<EOL>

Loads a single item, see also :func:`~pypet.trajectory.Trajectory.f_load_items`


def f_load_items(self, iterator, *args, **kwargs):

if not self._stored:<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>')<EOL><DEDENT>fetched_items = self._nn_interface._fetch_items(LOAD, iterator, args, kwargs)<EOL>if fetched_items:<EOL><INDENT>self._storage_service.load(pypetconstants.LIST, fetched_items,<EOL>trajectory_name=self.v_name)<EOL><DEDENT>else:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

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 results in the trajectory. Accordingly, the parameters and results
        you want to load must already exist in your trajectory (in RAM), probably they
        are just empty skeletons waiting desperately to handle data.
        If they do not exist in RAM yet, but have been stored to disk before,
        you can call :func:`~pypet.trajectory.Trajectory.f_load_skeleton` in order to
        bring your trajectory tree skeleton up to date. In case of a single run you can
        use the :func:`~pypet.naturalnaming.NNGroupNode.f_load_child` method to recursively
        load a subtree without any data.
        Then you can load the data of individual results or parameters one by one.

        If want to load the whole trajectory at once or ALL results and parameters that are
        still empty take a look at :func:`~pypet.trajectory.Trajectory.f_load`.
        As mentioned before, to load subtrees of your trajectory you might want to check out
        :func:`~pypet.naturalnaming.NNGroupNode.f_load_child`.

        To load a list of parameters or results with `f_load_items` you can pass
        the following arguments:

        :param iterator: A list with parameters or results to be loaded.

        :param only_empties:

            Optional keyword argument (boolean),
            if `True` only empty parameters or results are passed
            to the storage service to get loaded. Non-empty parameters or results found in
            `iterator` are simply ignored.

        :param args: Additional arguments directly passed to the storage service

        :param kwargs:

            Additional keyword arguments directly passed to the storage service
            (except the kwarg `only_empties`)

            If you use the standard hdf5 storage service, you can pass the following additional
            keyword arguments:

            :param load_only:

                If you load a result, you can partially load it and ignore the rest of data items.
                Just specify the name of the data you want to load. You can also provide a list,
                for example `load_only='spikes'`, `load_only=['spikes','membrane_potential']`.

                Be aware that you need to specify the names of parts as they were stored
                to HDF5. Depending on how your leaf construction works, this may differ
                from the names the data might have in your leaf in the trajectory container.

                A warning is issued if data specified in `load_only` cannot be found in the
                instances specified in `iterator`.

            :param load_except:

                Analogous to the above, but everything is loaded except names or parts
                specified in `load_except`.
                You cannot use `load_only` and `load_except` at the same time. If you do
                a ValueError is thrown.

                A warning is issued if names listed in `load_except` are not part of the
                items to load.


@kwargs_api_change('<STR_LIT>')<EOL><INDENT>def f_remove_item(self, item, recursive=False):<DEDENT>

self.f_remove_items([item], recursive=recursive)<EOL>

Removes a single item, see :func:`~pypet.trajectory.Trajectory.f_remove_items`


@kwargs_api_change('<STR_LIT>')<EOL><INDENT>def f_remove_items(self, iterator, recursive=False):<DEDENT>

<EOL>fetched_items = self._nn_interface._fetch_items(REMOVE, iterator, (), {})<EOL>if fetched_items:<EOL><INDENT>for _, item, dummy1, dummy2 in fetched_items:<EOL><INDENT>self._nn_interface._remove_node_or_leaf(item, recursive=recursive)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

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.trajectory.Trajectory.f_delete_items`.

        This will also remove all links if items are linked.

        :param iterator:

            A sequence of items you want to remove. Either the instances themselves
            or strings with the names of the items.

        :param recursive:

            In case you want to remove group nodes, if the children should be removed, too.


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

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

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


def f_delete_links(self, iterator_of_links, remove_from_trajectory=False):

to_delete_links = []<EOL>group_link_pairs = []<EOL>for elem in iterator_of_links:<EOL><INDENT>if isinstance(elem, str):<EOL><INDENT>split_names = elem.split('<STR_LIT:.>')<EOL>parent_name = '<STR_LIT:.>'.join(split_names[:-<NUM_LIT:1>])<EOL>link = split_names[-<NUM_LIT:1>]<EOL>parent_node = self.f_get(parent_name) if parent_name != '<STR_LIT>' else self<EOL>link_name = parent_node.v_full_name + '<STR_LIT:.>' + link if parent_name != '<STR_LIT>' else link<EOL>to_delete_links.append((pypetconstants.DELETE_LINK, link_name))<EOL>group_link_pairs.append((parent_node, link))<EOL><DEDENT>else:<EOL><INDENT>link_name = elem[<NUM_LIT:0>].v_full_name + '<STR_LIT:.>' + elem[<NUM_LIT:1>]<EOL>to_delete_links.append((pypetconstants.DELETE_LINK, link_name))<EOL>group_link_pairs.append(elem)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>self._storage_service.store(pypetconstants.LIST, to_delete_links,<EOL>trajectory_name=self.v_name)<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>' % str(to_delete_links))<EOL>raise<EOL><DEDENT>if remove_from_trajectory:<EOL><INDENT>for group, link in group_link_pairs:<EOL><INDENT>group.f_remove_link(link)<EOL><DEDENT><DEDENT>

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 ``(groupWithLink, 'linkA')``.


def f_remove(self, recursive=True, predicate=None):

if not recursive:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>for child in list(self._children.keys()):<EOL><INDENT>self.f_remove_child(child, recursive=True, predicate=predicate)<EOL><DEDENT>

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 predicate:

            Predicate which can evaluate for each node to ``True`` in order to remove the node or
            ``False`` if the node should be kept. Leave ``None`` if you want to remove all nodes.


@kwargs_api_change('<STR_LIT>')<EOL><INDENT>def f_delete_item(self, item, *args, **kwargs):<DEDENT>

self.f_delete_items([item], *args, **kwargs)<EOL>

Deletes a single item, see :func:`~pypet.trajectory.Trajectory.f_delete_items`


@kwargs_api_change('<STR_LIT>')<EOL><INDENT>def f_delete_items(self, iterator, *args, **kwargs):<DEDENT>

remove_from_trajectory = kwargs.pop('<STR_LIT>', False)<EOL>recursive = kwargs.get('<STR_LIT>', False)<EOL>fetched_items = self._nn_interface._fetch_items(REMOVE, iterator, args, kwargs)<EOL>if fetched_items:<EOL><INDENT>try:<EOL><INDENT>self._storage_service.store(pypetconstants.LIST, fetched_items,<EOL>trajectory_name=self.v_name)<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>' % str(fetched_items))<EOL>raise<EOL><DEDENT>for _, item, dummy1, dummy2 in fetched_items:<EOL><INDENT>if remove_from_trajectory:<EOL><INDENT>self._nn_interface._remove_node_or_leaf(item, recursive=recursive)<EOL><DEDENT>else:<EOL><INDENT>item._stored = False<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

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 sequence of items you want to remove. Either the instances themselves
            or strings with the names of the items.

        :param remove_from_trajectory:

            If items should also be removed from trajectory. Default is `False`.

        :param args: Additional arguments passed to the storage service

        :param kwargs: Additional keyword arguments passed to the storage service

            If you use the standard hdf5 storage service, you can pass the following additional
            keyword argument:

            :param delete_only:

                You can partially delete leaf nodes. Specify a list of parts of the result node
                that should be deleted like `delete_only=['mystuff','otherstuff']`.
                This wil only delete the hdf5 sub parts `mystuff` and `otherstuff` from disk.
                BE CAREFUL,
                erasing data partly happens at your own risk. Depending on how complex the
                loading process of your result node is, you might not be able to reconstruct
                any data due to partially deleting some of it.

                Be aware that you need to specify the names of parts as they were stored
                to HDF5. Depending on how your leaf construction works, this may differ
                from the names the data might have in your leaf in the trajectory container.

                If the hdf5 nodes you specified in `delete_only` cannot be found a warning
                is issued.

                Note that massive deletion will fragment your HDF5 file.
                Try to avoid changing data on disk whenever you can.

                If you want to erase a full node, simply ignore this argument or set to `None`.

            :param remove_from_item:

                If data that you want to delete from storage should also be removed from
                the items in `iterator` if they contain these. Default is `False`.

            :param recursive:

                If you want to delete a group node and it has children you need to
                set `recursive` to `True. Default is `False`.


result = super(Trajectory, self).__dir__()<EOL>if self._is_run:<EOL><INDENT>result = [x for x in result if not x.startswith('<STR_LIT>') or<EOL>not getattr(getattr(self, x), '<STR_LIT>', False)]<EOL><DEDENT>if not is_debug():<EOL><INDENT>result.extend(self._children.keys())<EOL><DEDENT>return result<EOL>

Adds all children to auto-completion

        In case of a single run it spares all non-available functions


return type(data) in pypetconstants.PARAMETER_SUPPORTED_DATA<EOL>

Checks whether the data is supported by the parameter.


return self._locked<EOL>

Whether or not the parameter is locked and prevents further modification


return not self.f_is_empty()<EOL>

Checks if parameter supports fast access.

        A parameter supports fast access if it is NOT empty!


return self._explored<EOL>

Whether parameter is explored.

        Does not necessarily have to be similar to
        :func:`~pypet.parameter.BaseParameter.f_has_range` since the range can be
        deleted on pickling and the parameter remains explored.


return self._full_copy<EOL>

Whether or not the full parameter including the range or only the current
        data is copied during pickling.

        If you run your simulations in multiprocessing mode, the whole trajectory and all
        parameters need to be pickled and are sent to the individual processes.
        Each process than runs an individual point in the parameter space.
        As a consequence, you do not need the full ranges during these calculations.
        Thus, if the full copy mode is set to `False` the parameter is pickled without
        the range array and you can save memory.

        If you want to access the full range during individual runs, you need to set
        `v_full_copy` to `True`.

        It is recommended NOT to do that in order to save memory and also do obey the
        philosophy that individual simulation runs are independent.

        Example usage:

        >>> import pickle
        >>> param = Parameter('examples.fullcopy', data=333, comment='I show you how the copy mode works!')
        >>> param._explore([1,2,3,4])
        >>> dump=pickle.dumps(param)
        >>> newparam = pickle.loads(dump)
        >>> newparam.f_get_range()
        TypeError

        >>> param.v_full_copy=True
        >>> dump = pickle.dumps(param)
        >>> newparam=pickle.loads(dump)
        >>> newparam.f_get_range()
        (1,2,3,4)


val = bool(val)<EOL>self._full_copy = val<EOL>


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

Returns true if the parameter contains a range array.

        Not necessarily equal to `v_explored` if the range is removed on
        pickling due to `v_full_copy=False`.

        ABSTRACT: Needs to be defined in subclass


Restores original data if changed due to exploration.

        If a Parameter is explored, the actual data is changed over the course of different
        simulations. This method restores the original data assigned before exploration.

        ABSTRACT: Needs to be defined in subclass


if not self.f_has_range():<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>elif hasattr(self, '<STR_LIT>'):<EOL><INDENT>return len(self)<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>

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.


old_locked = self._locked<EOL>try:<EOL><INDENT>return repr(self.f_get())<EOL><DEDENT>except Exception:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>finally:<EOL><INDENT>self._locked = old_locked<EOL><DEDENT>

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.


if self.f_supports(val1) != self.f_supports(val2):<EOL><INDENT>return False<EOL><DEDENT>if not self.f_supports(val1) and not self.f_supports(val2):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (str(type(val1)), str(type(val2))))<EOL><DEDENT>if not self._values_of_same_type(val1, val2):<EOL><INDENT>return False<EOL><DEDENT>return comparisons.nested_equal(val1, val2)<EOL>

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 not always implemented by values handled by
        parameters in the same way, the parameters need to judge whether their values are equal.

        The straightforward example here is a numpy array.
        Checking for equality of two numpy arrays yields
        a third numpy array containing truth values of a piecewise comparison.
        Accordingly, the parameter could judge two numpy arrays equal if ALL of the numpy
        array elements are equal.

        In this BaseParameter class values are considered to be equal if they obey
        the function :func:`~pypet.utils.comparisons.nested_equal`.
        You might consider implementing a different equality comparison in your subclass.

        :raises: TypeError: If both values are not supported by the parameter.


def _values_of_same_type(self, val1, val2):

if self.f_supports(val1) != self.f_supports(val2):<EOL><INDENT>return False<EOL><DEDENT>if not self.f_supports(val1) and not self.f_supports(val2):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>str(type(val1)), str(type(val2)))<EOL><DEDENT>return type(val1) is type(val2)<EOL>

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
        is of the same type as the default value.

        One could always come up with a trivial solution of `type(val1) is type(val2)`.
        But sometimes your parameter does want even more strict equality or
        less type equality.

        For example, the :class:`~pypet.parameter.Parameter` has a stricter sense of
        type equality regarding numpy arrays. In order to have two numpy arrays of the same type,
        they must also agree in shape. However, the :class:`~pypet.parameter.ArrayParameter`,
        considers all numpy arrays as of being of same type regardless of their shape.

        Moreover, the :class:`~pypet.parameter.SparseParameter` considers all supported
        sparse matrices (csc, csr, bsr, dia) as being of the same type. You can make
        explorations using all these four types at once.

        The difference in how strict types are treated arises from the way parameter data
        is stored to disk and how the parameters hand over their data to the storage service
        (see :func:`pypet.parameter.BaseParameter._store`).

        The :class:`~pypet.parameter.Parameter` puts all it's data in an
        :class:`~pypet.parameter.ObjectTable` which
        has strict constraints on the column sizes. This means that numpy array columns only
        accept numpy arrays with a particular size. In contrast, the array and sparse
        parameter hand over their data as individual items which yield individual entries
        in the hdf5 node. In order to see what I mean simply run an experiment with all 3
        parameters, explore all of them, and take a look at the resulting hdf5 file!

        However, this BaseParameter class implements the straightforward version of
        `type(val1) is type(val2)` to consider data to be of the same type.

        :raises: TypeError: if both values are not supported by the parameter.


if self.f_has_range():<EOL><INDENT>lenstr = '<STR_LIT>' % self.f_get_range_length()<EOL><DEDENT>else:<EOL><INDENT>lenstr = '<STR_LIT>'<EOL><DEDENT>if self.v_comment:<EOL><INDENT>commentstr = '<STR_LIT>' % self.v_comment<EOL><DEDENT>else:<EOL><INDENT>commentstr = '<STR_LIT>'<EOL><DEDENT>if commentstr or lenstr:<EOL><INDENT>if commentstr and lenstr:<EOL><INDENT>combined_str = '<STR_LIT>' % (lenstr, commentstr)<EOL><DEDENT>elif commentstr:<EOL><INDENT>combined_str = commentstr<EOL><DEDENT>elif lenstr:<EOL><INDENT>combined_str = lenstr<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>infostr = '<STR_LIT>' % combined_str<EOL><DEDENT>else:<EOL><INDENT>infostr = '<STR_LIT>'<EOL><DEDENT>return_string = '<STR_LIT>' % (self.f_get_class_name(), self.v_full_name, infostr)<EOL>if not self.f_is_empty():<EOL><INDENT>return_string += '<STR_LIT>' + self.f_val_to_str()<EOL><DEDENT>return return_string<EOL>

String representation of the Parameter

        Output format is:`<class_name> full_name (len:X, `comment`): value`.
        If comment is the empty string, the comment is omitted.
        If the parameter is not explored the length is omitted.


self._locked = False<EOL>

Unlocks the locked parameter.

        Please use it very carefully, or best do not use this function at all.
        There should better be no reason to unlock a locked parameter!
        The only exception I can think of is to unlock a large derived parameter
        after usage to subsequently call :func:`~pypet.parameter.BaseParameter.f_empty`
        to clear memory.


self._locked = True<EOL>

Locks the parameter and forbids further manipulation.

        Changing the data value or exploration range of the parameter are no longer allowed.


Sets a data value for a parameter.

        Example usage:

        >>> param = Parameter('groupA.groupB.myparam', comment='I am a neat example')
        >>> param.f_set(44.0)
        >>> param.f_get()
        44.0

        :raises:

                ParameterLockedException: If parameter is locked

                TypeError: If the type of the data value is not supported by the parameter

        ABSTRACT: Needs to be defined in subclass


return self.f_get_range().__getitem__(item)<EOL>

Equivalent to `f_get_range()[idx]`

        :raises: TypeError if parameter has no range


Returns the current data value of the parameter and locks the parameter.

        :raises: TypeError if the parameter is empty

        Example usage:

        >>> param = Parameter('groupA.groupB.myparam', comment='I am a neat example')
        >>> param.f_set(44.0)
        >>> param.f_get()
        44.0:

        ABSTRACT: Needs to be defined in subclass


Returns the default value of the parameter and locks it.


Returns an iterable to iterate over the values of the exploration range.

        Note that the returned values should be either a copy of the exploration range
        unless explicetly requested otherwise.

        :param copy:

            If range should be copied to avoid tempering with data.

        :return: Iterable

        :raises: TypeError if the parameter is not explored

        Example usage:

        >>> param = Parameter('groupA.groupB.myparam',data=22, comment='I am a neat example')
        >>> param._explore([42,43,43])
        >>> param.f_get_range()
        (42,43,44)

        ABSTRACT: Needs to be defined in subclass


The method to explore a parameter and create a range of entries.

        :param iterable: An iterable specifying the exploration range

             For example:

             >>> param = Parameter('groupA.groupB.myparam',data=22.33,\
              comment='I am a neat example')
             >>> param._explore([3.0,2.0,1.0])

        :raises:

            ParameterLockedException: If the parameter is locked

            TypeError: If the parameter is already explored

        ABSTRACT: Needs to be defined in subclass


Similar to :func:`~pypet.parameter.BaseParameter._explore` but appends to
        the exploration range.

        :param iterable: An iterable specifying the exploration range.

        :raises:

            ParameterLockedException: If the parameter is locked

            TypeError: If the parameter did not have a range before

        Example usage:

        >>> param = Parameter('groupA.groupB.myparam', data=3.13, comment='I am a neat example')
        >>> param._explore([3.0,2.0,1.0])
        >>> param._expand([42.0,43.0])
        >>> param.f_get_range()
        (3.0,2.0,1.0,42.0,43.0)

        ABSTRACT: Needs to be defined in subclass


Sets the current value according to the `idx` in the exploration range.

        Prepares the parameter for further usage, and tells it which point in the parameter
        space should be accessed by calls to :func:`~pypet.parameter.BaseParameter.f_get`.

        :param idx: The index within the exploration range.

            If the parameter has no range, the single data value is considered
            regardless of the value of `idx`.
            Raises ValueError if the parameter is explored and `idx>=len(param)`.

        :raises: ValueError:

            If the parameter has a range and `idx` is larger or equal to the
            length of the parameter.

        Example usage:

        >>> param = Parameter('groupA.groupB.myparam',data=22.33, comment='I am a neat example')
        >>> param._explore([42.0,43.0,44.0])
        >>> param._set_parameter_access(idx=1)
        >>> param.f_get()
        43.0

        ABSTRACT: Needs to be defined in subclass


return self.__class__.__name__<EOL>

Returns the name of the class i.e. `return self.__class__.__name__`


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

True if no data has been assigned to the parameter.

        Example usage:

        >>> param = Parameter('myname.is.example', comment='I am _empty!')
        >>> param.f_is_empty()
        True
        >>> param.f_set(444)
        >>> param.f_is_empty()
        False


If a parameter is explored, i.e. it has a range, the whole exploration range is deleted.

        Note that this function does not erase data from disk. So if the parameter has
        been stored with a service to disk and is shrunk, it can be restored by loading from disk.

        :raises:

            ParameterLockedException: If the parameter is locked

            TypeError: If the parameter has no range

        ABSTRACT: Needs to be defined in subclass


Erases all data in the parameter.

        Does not erase data from disk. So if the parameter has
        been stored with a service to disk and is emptied,
        it can be restored by loading from disk.

        :raises: ParameterLockedException: If the parameter is locked.

        ABSTRACT: Needs to be defined in subclass


self._data = self._default<EOL>

Restores the default data that was set with the
        `:func:`~pypet.parameter.Parameter.f_set` method (or at initialisation).

        If the parameter is explored during the runtime of a simulation,
        the actual value of the parameter is changed and taken from the exploration range.
        Calling :func:`~pypet.parameter.Parameter._restore_default` sets the parameter's value
        back to it's original value.

        Example usage:

        >>> param = Parameter('supergroup1.subgroup2.', data=44, comment='Im a comment!')
        >>> param._explore([1,2,3,4])
        >>> param._set_parameter_access(2)
        >>> param.f_get()
        3
        >>> param._restore_default()
        >>> param.f_get()
        44


return self._data is None<EOL>


if self._data is None:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>elif len(self._explored_range) > <NUM_LIT:0>:<EOL><INDENT>return len(self._explored_range)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>

Returns length of parameter.

        :return:

            0 if empty

            1 if not explored

            length of range if explored and has range


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

If the parameter has a range.

        Does not have to be `True` if the parameter is explored.
        The range might be removed during pickling to save memory.
        Accordingly, `v_explored` remains `True` whereas `f_has_range` is `False`.


result = super(Parameter, self).__getstate__()<EOL>if not self._full_copy:<EOL><INDENT>result['<STR_LIT>'] = []<EOL><DEDENT>return result<EOL>

Returns the actual state of the parameter for pickling.

        If `v_full_copy` is true the exploration range is also pickled, otherwise it is omitted.


if item == '<STR_LIT:data>':<EOL><INDENT>return self.f_get()<EOL><DEDENT>elif item == '<STR_LIT:default>':<EOL><INDENT>return self.f_get_default()<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>' % (self.f_get_class_name(),<EOL>item))<EOL><DEDENT>

Allows to query for `.data` as an attribute


if item == '<STR_LIT:data>':<EOL><INDENT>return self.f_get()<EOL><DEDENT>elif item == '<STR_LIT:default>' or item == -<NUM_LIT:1>:<EOL><INDENT>return self.f_get_default()<EOL><DEDENT>else:<EOL><INDENT>return super(Parameter, self).__getitem__(item)<EOL><DEDENT>

Equivalent to `f_get_range[item] if item is integer`

        Allows also ['data'] access which is equivalent to `f_get`

        :raises: TypeError if parameter has no range


dtype = type(data)<EOL>if dtype is tuple or dtype is list:<EOL><INDENT>if len(data) == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>old_type = None<EOL>for item in data:<EOL><INDENT>if not type(item) in pypetconstants.PARAMETER_SUPPORTED_DATA:<EOL><INDENT>return False<EOL><DEDENT>if not old_type is None and old_type != type(item):<EOL><INDENT>return False<EOL><DEDENT>old_type = type(item)<EOL><DEDENT>return True<EOL><DEDENT>elif dtype is np.ndarray or dtype is np.matrix:<EOL><INDENT>if data.size == <NUM_LIT:0>:<EOL><INDENT>return False <EOL><DEDENT>dtype = data.dtype<EOL>if np.issubdtype(dtype, np.str):<EOL><INDENT>dtype = np.str<EOL><DEDENT><DEDENT>return dtype in pypetconstants.PARAMETER_SUPPORTED_DATA<EOL>

Checks if input data is supported by the parameter.


if self.f_supports(val1) != self.f_supports(val2):<EOL><INDENT>return False<EOL><DEDENT>if not self.f_supports(val1) and not self.f_supports(val2):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>str(type(val1)), str(type(val2)))<EOL><DEDENT>if not type(val1) is type(val2):<EOL><INDENT>return False<EOL><DEDENT>if type(val1) is np.array:<EOL><INDENT>if not val1.dtype is val2.dtype:<EOL><INDENT>return False<EOL><DEDENT>if not np.shape(val1) == np.shape(val2):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if type(val1) is tuple:<EOL><INDENT>return (type(val1[<NUM_LIT:0>]) is type(val2[<NUM_LIT:0>])) and (len(val1) == len(val2))<EOL><DEDENT>return True<EOL>

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,43)
        True

        >>>param._values_of_same_type(42,'43')
        False

        :raises: TypeError


if not self.f_has_range():<EOL><INDENT>raise TypeError('<STR_LIT>' %<EOL>self.v_full_name)<EOL><DEDENT>elif copy:<EOL><INDENT>return self._explored_range[:]<EOL><DEDENT>else:<EOL><INDENT>return self._explored_range<EOL><DEDENT>

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 a neat example')
        >>> param._explore([42,43,43])
        >>> param.f_get_range()
        (42,43,44)

        :raises: TypeError: If parameter is not explored.


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>if self.f_has_range():<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % self._name)<EOL><DEDENT>if self._data is None:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % self.v_full_name)<EOL><DEDENT>data_list = self._data_sanity_checks(explore_iterable)<EOL>self._explored_range = data_list<EOL>self._explored = True<EOL>self.f_lock()<EOL>

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 default value,
        or the parameter has already an exploration range.

        Note that the parameter will iterate over the whole iterable once and store
        the individual data values into a tuple. Thus, the whole exploration range is
        explicitly stored in memory.

        :param explore_iterable: An iterable specifying the exploration range

        For example:

        >>> param._explore([3.0,2.0,1.0])
        >>> param.f_get_range()
        (3.0, 2.0, 1.0)

        :raises TypeError,ParameterLockedException


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>if not self.f_has_range():<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % self._name)<EOL><DEDENT>data_list = self._data_sanity_checks(explore_iterable)<EOL>self._explored_range.extend(data_list)<EOL>self.f_lock()<EOL>

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 are not the same as the type of the default value,
        or the parameter did not have an array before.

        Note that the parameter will iterate over the whole iterable once and store
        the individual data values into a tuple. Thus, the whole exploration range is
        explicitly stored in memory.

        :param explore_iterable: An iterable specifying the exploration range

         For example:

         >>> param = Parameter('Im.an.example', data=33.33, comment='Wooohoo!')
         >>> param._explore([3.0,2.0,1.0])
         >>> param._expand([42.0, 43.42])
         >>> param.f_get_range()
         >>> [3.0, 2.0, 1.0, 42.0, 43.42]

        :raises TypeError, ParameterLockedException


data_list = []<EOL>for val in explore_iterable:<EOL><INDENT>if not self.f_supports(val):<EOL><INDENT>raise TypeError('<STR_LIT>' % (repr(val), str(type(val))))<EOL><DEDENT>if not self._values_of_same_type(val, self._default):<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(self.v_full_name, str(type(val)), str(type(self._default))))<EOL><DEDENT>data_list.append(val)<EOL><DEDENT>if len(data_list) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return data_list<EOL>

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.


if self._data is not None:<EOL><INDENT>store_dict = {'<STR_LIT:data>': ObjectTable(data={'<STR_LIT:data>': [self._data]})}<EOL><DEDENT>if self.f_has_range():<EOL><INDENT>store_dict['<STR_LIT>'] = ObjectTable(data={'<STR_LIT:data>': self._explored_range})<EOL><DEDENT>self._locked = True<EOL>return store_dict<EOL>

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'.

        :return: Dictionary containing the data and optionally the exploration range.


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>if '<STR_LIT:data>' in load_dict:<EOL><INDENT>self._data = load_dict['<STR_LIT:data>']['<STR_LIT:data>'][<NUM_LIT:0>]<EOL>self._default = self._data<EOL><DEDENT>else:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>' % self.v_full_name)<EOL><DEDENT>if '<STR_LIT>' in load_dict:<EOL><INDENT>self._explored_range = [x for x in load_dict['<STR_LIT>']['<STR_LIT:data>'].tolist()]<EOL>self._explored = True<EOL><DEDENT>self._locked = True<EOL>

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 type(self._data) not in (np.ndarray, tuple, np.matrix, list):<EOL><INDENT>return super(ArrayParameter, self)._store()<EOL><DEDENT>else:<EOL><INDENT>store_dict = {'<STR_LIT:data>' + ArrayParameter.IDENTIFIER: self._data}<EOL>if self.f_has_range():<EOL><INDENT>smart_dict = {}<EOL>store_dict['<STR_LIT>' + ArrayParameter.IDENTIFIER] =ObjectTable(columns=['<STR_LIT>'], index=list(range(len(self))))<EOL>count = <NUM_LIT:0><EOL>for idx, elem in enumerate(self._explored_range):<EOL><INDENT>if isinstance(elem, np.ndarray):<EOL><INDENT>hash_elem = HashArray(elem)<EOL><DEDENT>elif isinstance(elem, list):<EOL><INDENT>hash_elem = tuple(elem)<EOL><DEDENT>else:<EOL><INDENT>hash_elem = elem<EOL><DEDENT>if hash_elem in smart_dict:<EOL><INDENT>name_idx = smart_dict[hash_elem]<EOL>add = False<EOL><DEDENT>else:<EOL><INDENT>name_idx = count<EOL>add = True<EOL><DEDENT>name = self._build_name(name_idx)<EOL>store_dict['<STR_LIT>' + ArrayParameter.IDENTIFIER]['<STR_LIT>'][idx] =name_idx<EOL>if add:<EOL><INDENT>store_dict[name] = elem<EOL>smart_dict[hash_elem] = name_idx<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>self._locked = True<EOL>return store_dict<EOL><DEDENT>

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__rr__'.

        Each array of the exploration range is stored as a separate entry named
        'xa__rr__XXXXXXXX' where 'XXXXXXXX' is the index of the array. Note if an array
        is used more than once in an exploration range (for example, due to cartesian product
        exploration), the array is stored only once.
        Moreover, an :class:`~pypet.parameter.ObjectTable` containing the references
        is stored under the name 'explored_data__rr__' in order to recall
        the order of the arrays later on.


return '<STR_LIT>' % (ArrayParameter.IDENTIFIER,<EOL>name_idx // <NUM_LIT:1000>, name_idx)<EOL>

Formats a name for storage

        :return:

            'xa__rr__XXXXXXXX' where 'XXXXXXXX' is the index of the array


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>try:<EOL><INDENT>self._data = load_dict['<STR_LIT:data>' + ArrayParameter.IDENTIFIER]<EOL>if '<STR_LIT>' + ArrayParameter.IDENTIFIER in load_dict:<EOL><INDENT>explore_table = load_dict['<STR_LIT>' + ArrayParameter.IDENTIFIER]<EOL>idx = explore_table['<STR_LIT>']<EOL>explore_list = []<EOL>for name_idx in idx:<EOL><INDENT>arrayname = self._build_name(name_idx)<EOL>explore_list.append(load_dict[arrayname])<EOL><DEDENT>self._explored_range = [x for x in explore_list]<EOL>self._explored = True<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>super(ArrayParameter, self)._load(load_dict)<EOL><DEDENT>self._default = self._data<EOL>self._locked = True<EOL>

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 arrays is reconstructed
        as it was stored in :func:`~pypet.parameter.ArrayParameter._store`.


if (type(val1) in (np.ndarray, tuple, np.matrix)) and (type(val2) is type(val1)):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return super(ArrayParameter, self)._values_of_same_type(val1, val2)<EOL><DEDENT>

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.


dtype = type(data)<EOL>if dtype is tuple or dtype is list and len(data) == <NUM_LIT:0>:<EOL><INDENT>return True  <EOL><DEDENT>elif dtype is np.ndarray and data.size == <NUM_LIT:0> and data.ndim == <NUM_LIT:1>:<EOL><INDENT>return True  <EOL><DEDENT>else:<EOL><INDENT>return super(ArrayParameter, self).f_supports(data)<EOL><DEDENT>


if self._is_supported_matrix(val1) and self._is_supported_matrix(val2):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return super(SparseParameter, self)._values_of_same_type(val1, val2)<EOL><DEDENT>

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.


if self._is_supported_matrix(val1):<EOL><INDENT>if self._is_supported_matrix(val2):<EOL><INDENT>_, _, hash_tuple_1 = self._serialize_matrix(val1)<EOL>_, _, hash_tuple_2 = self._serialize_matrix(val2)<EOL>return hash(hash_tuple_1) == hash(hash_tuple_2)<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return super(SparseParameter, self)._equal_values(val1, val2)<EOL><DEDENT>

Matrices are equal if they hash to the same value.


return (spsp.isspmatrix_csc(data) or<EOL>spsp.isspmatrix_csr(data) or<EOL>spsp.isspmatrix_bsr(data) or<EOL>spsp.isspmatrix_dia(data))<EOL>

Checks if a data is csr, csc, bsr, or dia Scipy sparse matrix


if self._is_supported_matrix(data):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return super(SparseParameter, self).f_supports(data)<EOL><DEDENT>

Sparse matrices support Scipy csr, csc, bsr and dia matrices and everything their parent
        class the :class:`~pypet.parameter.ArrayParameter` supports.


if (spsp.isspmatrix_csc(matrix) or<EOL>spsp.isspmatrix_csr(matrix) or<EOL>spsp.isspmatrix_bsr(matrix)):<EOL><INDENT>if matrix.size > <NUM_LIT:0>:<EOL><INDENT>return_list = [matrix.data, matrix.indices, matrix.indptr, matrix.shape]<EOL><DEDENT>else:<EOL><INDENT>return_list = ['<STR_LIT>', (), (), matrix.shape]<EOL><DEDENT>return_names = SparseParameter.OTHER_NAME_LIST<EOL>if spsp.isspmatrix_csc(matrix):<EOL><INDENT>return_list = ['<STR_LIT>'] + return_list<EOL><DEDENT>elif spsp.isspmatrix_csr(matrix):<EOL><INDENT>return_list = ['<STR_LIT>'] + return_list<EOL><DEDENT>elif spsp.isspmatrix_bsr(matrix):<EOL><INDENT>return_list = ['<STR_LIT>'] + return_list<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT>elif spsp.isspmatrix_dia(matrix):<EOL><INDENT>if matrix.size > <NUM_LIT:0>:<EOL><INDENT>return_list = ['<STR_LIT>', matrix.data, matrix.offsets, matrix.shape]<EOL><DEDENT>else:<EOL><INDENT>return_list = ['<STR_LIT>', '<STR_LIT>', (), matrix.shape]<EOL><DEDENT>return_names = SparseParameter.DIA_NAME_LIST<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>hash_list = []<EOL>for item in return_list:<EOL><INDENT>if type(item) is np.ndarray:<EOL><INDENT>hash_list.append(HashArray(item))<EOL><DEDENT>else:<EOL><INDENT>hash_list.append(item)<EOL><DEDENT><DEDENT>return return_list, return_names, tuple(hash_list)<EOL>

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 matrices the following attributes are extracted:
                `format`, `data`, `indices`, `indptr`, `shape`.
                Where format is simply one of the strings 'csr', 'csc', or 'bsr'.

                For dia matrices the following attributes are extracted:
                `format`, `data`, `offsets`, `shape`.
                Where `format` is simply the string 'dia'.

            2.

                A list containing the names of the extracted attributes.
                For csr, csc, and bsr:

                    [`format`, `data`, `indices`, `indptr`, `shape`]

                For dia:

                    [`format`, `data`, `offsets`, `shape`]

            3.

                A tuple containing the hashable parts of (1) in order to use the tuple as
                a key for a dictionary. Accordingly, the numpy arrays of (1) are
                changed to read-only.


if not self._is_supported_matrix(self._data):<EOL><INDENT>return super(SparseParameter, self)._store()<EOL><DEDENT>else:<EOL><INDENT>store_dict = {}<EOL>data_list, name_list, hash_tuple = self._serialize_matrix(self._data)<EOL>rename_list = ['<STR_LIT>' % (SparseParameter.IDENTIFIER, name)<EOL>for name in name_list]<EOL>is_dia = int(len(rename_list) == <NUM_LIT:4>)<EOL>store_dict['<STR_LIT>' % SparseParameter.IDENTIFIER] = is_dia<EOL>for idx, name in enumerate(rename_list):<EOL><INDENT>store_dict[name] = data_list[idx]<EOL><DEDENT>if self.f_has_range():<EOL><INDENT>smart_dict = {}<EOL>store_dict['<STR_LIT>' + SparseParameter.IDENTIFIER] =ObjectTable(columns=['<STR_LIT>', '<STR_LIT>'],<EOL>index=list(range(len(self))))<EOL>count = <NUM_LIT:0><EOL>for idx, elem in enumerate(self._explored_range):<EOL><INDENT>data_list, name_list, hash_tuple = self._serialize_matrix(elem)<EOL>if hash_tuple in smart_dict:<EOL><INDENT>name_idx = smart_dict[hash_tuple]<EOL>add = False<EOL><DEDENT>else:<EOL><INDENT>name_idx = count<EOL>add = True<EOL><DEDENT>is_dia = int(len(name_list) == <NUM_LIT:4>)<EOL>rename_list = self._build_names(name_idx, is_dia)<EOL>store_dict['<STR_LIT>' + SparseParameter.IDENTIFIER]['<STR_LIT>'][idx] = name_idx<EOL>store_dict['<STR_LIT>' + SparseParameter.IDENTIFIER]['<STR_LIT>'][<EOL>idx] = is_dia<EOL>if add:<EOL><INDENT>for irun, name in enumerate(rename_list):<EOL><INDENT>store_dict[name] = data_list[irun]<EOL><DEDENT>smart_dict[hash_tuple] = name_idx<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>self._locked = True<EOL>return store_dict<EOL><DEDENT>

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.SparseParameter._serialize_matrix` and these are named
        'data__spsp__XXXX' where 'XXXX' is a particular property of the matrix.

        The exploration range is handled similar as in the parent class. Yet, the matrices
        are split into the relevant parts and each part is stored as
        'xspm__spsp__XXXX__spsp__XXXXXXXX` where the first 'XXXX' refer to the property and
        the latter 'XXXXXXX' to the sparse matrix index.

        The :class:`~pypet.parameter.ObjectTable` `explored_data__spsp__` stores the order
        of the matrices and whether the corresponding matrix is dia or not.


def _build_names(self, name_idx, is_dia):

name_list = self._get_name_list(is_dia)<EOL>return tuple(['<STR_LIT>' % (SparseParameter.IDENTIFIER,<EOL>name_idx // <NUM_LIT:200>, name, name_idx)<EOL>for name in name_list])<EOL>

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.


def _build_names_old(self, name_idx, is_dia):

name_list = self._get_name_list(is_dia)<EOL>return tuple(['<STR_LIT>' % (SparseParameter.IDENTIFIER, name,<EOL>SparseParameter.IDENTIFIER, name_idx)<EOL>for name in name_list])<EOL>


matrix_format = data_list[<NUM_LIT:0>]<EOL>data = data_list[<NUM_LIT:1>]<EOL>is_empty = isinstance(data, str) and data == '<STR_LIT>'<EOL>if matrix_format == '<STR_LIT>':<EOL><INDENT>if is_empty:<EOL><INDENT>return spsp.csc_matrix(data_list[<NUM_LIT:4>])<EOL><DEDENT>else:<EOL><INDENT>return spsp.csc_matrix(tuple(data_list[<NUM_LIT:1>:<NUM_LIT:4>]), shape=data_list[<NUM_LIT:4>])<EOL><DEDENT><DEDENT>elif matrix_format == '<STR_LIT>':<EOL><INDENT>if is_empty:<EOL><INDENT>return spsp.csr_matrix(data_list[<NUM_LIT:4>])<EOL><DEDENT>else:<EOL><INDENT>return spsp.csr_matrix(tuple(data_list[<NUM_LIT:1>:<NUM_LIT:4>]), shape=data_list[<NUM_LIT:4>])<EOL><DEDENT><DEDENT>elif matrix_format == '<STR_LIT>':<EOL><INDENT>if is_empty:<EOL><INDENT>return spsp.bsr_matrix(data_list[<NUM_LIT:4>])<EOL><DEDENT>else:<EOL><INDENT>return spsp.bsr_matrix(tuple(data_list[<NUM_LIT:1>:<NUM_LIT:4>]), shape=data_list[<NUM_LIT:4>])<EOL><DEDENT><DEDENT>elif matrix_format == '<STR_LIT>':<EOL><INDENT>if is_empty:<EOL><INDENT>return spsp.dia_matrix(data_list[<NUM_LIT:3>])<EOL><DEDENT>else:<EOL><INDENT>return spsp.dia_matrix(tuple(data_list[<NUM_LIT:1>:<NUM_LIT:3>]), shape=data_list[<NUM_LIT:3>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>

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`


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>try:<EOL><INDENT>is_dia = load_dict['<STR_LIT>' % SparseParameter.IDENTIFIER]<EOL>name_list = self._get_name_list(is_dia)<EOL>rename_list = ['<STR_LIT>' % (SparseParameter.IDENTIFIER, name)<EOL>for name in name_list]<EOL>data_list = [load_dict[name] for name in rename_list]<EOL>self._data = self._reconstruct_matrix(data_list)<EOL>if '<STR_LIT>' + SparseParameter.IDENTIFIER in load_dict:<EOL><INDENT>explore_table = load_dict['<STR_LIT>' + SparseParameter.IDENTIFIER]<EOL>idx_col = explore_table['<STR_LIT>']<EOL>dia_col = explore_table['<STR_LIT>']<EOL>explore_list = []<EOL>for irun, name_id in enumerate(idx_col):<EOL><INDENT>is_dia = dia_col[irun]<EOL>try:<EOL><INDENT>name_list = self._build_names(name_id, is_dia)<EOL>data_list = [load_dict[name] for name in name_list]<EOL><DEDENT>except KeyError:<EOL><INDENT>name_list = self._build_names_old(name_id, is_dia)<EOL>data_list = [load_dict[name] for name in name_list]<EOL><DEDENT>matrix = self._reconstruct_matrix(data_list)<EOL>explore_list.append(matrix)<EOL><DEDENT>self._explored_range = explore_list<EOL>self._explored = True<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>super(SparseParameter, self)._load(load_dict)<EOL><DEDENT>self._default = self._data<EOL>self._locked = True<EOL>

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 range of matrices is reconstructed
        as it was stored in :func:`~pypet.parameter.SparseParameter._store`.


return self._protocol<EOL>

The protocol used to pickle data, default is 0.

        See pickle_ documentation for the protocols.

        .. _pickle: http://docs.python.org/2/library/pickle.html


self._protocol = value<EOL>


return True<EOL>

There is no straightforward check if an object can be pickled and this function will
        always return `True`.

        So you have to take care in advance that the item can be pickled.


return '<STR_LIT>' % name_id<EOL>

Formats names for storage

        Explored data is stored as 'xp_XXXXXXXX' where 'XXXXXXXX' is the index of the object.


store_dict = {}<EOL>if self._data is not None:<EOL><INDENT>dump = pickle.dumps(self._data, protocol=self.v_protocol)<EOL>store_dict['<STR_LIT:data>'] = dump<EOL>store_dict[PickleParameter.PROTOCOL] = self.v_protocol<EOL><DEDENT>if self.f_has_range():<EOL><INDENT>store_dict['<STR_LIT>'] =ObjectTable(columns=['<STR_LIT>'], index=list(range(len(self))))<EOL>smart_dict = {}<EOL>count = <NUM_LIT:0><EOL>for idx, val in enumerate(self._explored_range):<EOL><INDENT>obj_id = id(val)<EOL>if obj_id in smart_dict:<EOL><INDENT>name_id = smart_dict[obj_id]<EOL>add = False<EOL><DEDENT>else:<EOL><INDENT>name_id = count<EOL>add = True<EOL><DEDENT>name = self._build_name(name_id)<EOL>store_dict['<STR_LIT>']['<STR_LIT>'][idx] = name_id<EOL>if add:<EOL><INDENT>store_dict[name] = pickle.dumps(val, protocol=self.v_protocol)<EOL>smart_dict[obj_id] = name_id<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>self._locked = True<EOL>return store_dict<EOL>

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 able to recall the
        order of objects later on.


if self.v_locked:<EOL><INDENT>raise pex.ParameterLockedException('<STR_LIT>' % self.v_full_name)<EOL><DEDENT>if '<STR_LIT:data>' in load_dict:<EOL><INDENT>dump = load_dict['<STR_LIT:data>']<EOL>self._data = pickle.loads(dump)<EOL><DEDENT>else:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>' % self.v_full_name)<EOL><DEDENT>try:<EOL><INDENT>self.v_protocol = load_dict[PickleParameter.PROTOCOL]<EOL><DEDENT>except KeyError:<EOL><INDENT>self.v_protocol = PickleParameter._get_protocol(dump)<EOL><DEDENT>if '<STR_LIT>' in load_dict:<EOL><INDENT>explore_table = load_dict['<STR_LIT>']<EOL>name_col = explore_table['<STR_LIT>']<EOL>explore_list = []<EOL>for name_id in name_col:<EOL><INDENT>arrayname = self._build_name(name_id)<EOL>loaded = pickle.loads(load_dict[arrayname])<EOL>explore_list.append(loaded)<EOL><DEDENT>self._explored_range = explore_list<EOL>self._explored = True<EOL><DEDENT>self._default = self._data<EOL>self._locked = True<EOL>

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'.


if self._data_ is None:<EOL><INDENT>self._data_ = {}<EOL><DEDENT>return self._data_<EOL>

To avoid the overhead of producing an empty dictionary


result = super(Result, self).__dir__()<EOL>if self._data_ is not None:<EOL><INDENT>result.extend(self._data.keys())<EOL><DEDENT>return result<EOL>


if isinstance(key, int):<EOL><INDENT>if key == <NUM_LIT:0>:<EOL><INDENT>key = self.v_name<EOL><DEDENT>else:<EOL><INDENT>key = self.v_name + '<STR_LIT>' % key<EOL><DEDENT><DEDENT>return key<EOL>

Translates integer indices into the appropriate names


resstrlist = []<EOL>strlen = <NUM_LIT:0><EOL>for key in self._data:<EOL><INDENT>val = self._data[key]<EOL>resstr = '<STR_LIT>' % (key, repr(val))<EOL>resstrlist.append(resstr)<EOL>strlen += len(resstr)<EOL>if strlen > pypetconstants.HDF5_STRCOL_MAX_VALUE_LENGTH:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return_string = "<STR_LIT>".join(resstrlist)<EOL>if len(return_string) > pypetconstants.HDF5_STRCOL_MAX_VALUE_LENGTH:<EOL><INDENT>return_string =return_string[<NUM_LIT:0>:pypetconstants.HDF5_STRCOL_MAX_VALUE_LENGTH - <NUM_LIT:3>] + '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return_string = return_string[<NUM_LIT:0>:-<NUM_LIT:2>] <EOL><DEDENT>return return_string<EOL>

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


datastr = self.f_val_to_str()<EOL>return_string = '<STR_LIT>' % (self.f_get_class_name(), self.v_full_name)<EOL>if self.v_comment:<EOL><INDENT>return_string += '<STR_LIT>' % self.v_comment<EOL><DEDENT>if datastr:<EOL><INDENT>return_string += '<STR_LIT>' + datastr<EOL><DEDENT>return return_string<EOL>

String representation of the result.

        Output format is '<class_name> name (`comment`): value_string'

        The `value_string` is obtained from :func:`~pypet.parameter.Result.f_val_to_str`.

        If the comment is the empty string, the comment is omitted.


if copy:<EOL><INDENT>return self._data.copy()<EOL><DEDENT>else:<EOL><INDENT>return self._data<EOL><DEDENT>

Returns all handled data as a dictionary.

        :param copy:

            Whether the original dictionary or a shallow copy is returned.

        :return: Data dictionary


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

True if no data has been put into the result.

        Also True if all data has been erased via :func:`~pypet.parameter.Result.f_empty`.


if args and self.v_name is None:<EOL><INDENT>raise AttributeError('<STR_LIT>')<EOL><DEDENT>for idx, arg in enumerate(args):<EOL><INDENT>valstr = self.f_translate_key(idx)<EOL>self.f_set_single(valstr, arg)<EOL><DEDENT>for key, arg in kwargs.items():<EOL><INDENT>self.f_set_single(key, arg)<EOL><DEDENT>

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: Arguments are stored with the key as name.

        :raises: TypeError if outer data structure is not understood.

        Example usage:

        >>> res = Result('supergroup.subgroup.myresult', comment='I am a neat example!')
        >>> res.f_set(333,42.0, mystring='String!')
        >>> res.f_get('myresult')
        333
        >>> res.f_get('myresult_1')
        42.0
        >>> res.f_get(1)
        42.0
        >>> res.f_get('mystring')
        'String!'


return self.f_get(name)<EOL>


key = self.f_translate_key(key)<EOL>setattr(self, key, value)<EOL>

Almost equivalent to calling __setattr__.

        Treats integer values as `f_get`.


return self._data.__iter__()<EOL>

Equivalent to iterating over the keys of the data dictionary.


if len(args) == <NUM_LIT:0>:<EOL><INDENT>if len(self._data) == <NUM_LIT:1>:<EOL><INDENT>return list(self._data.values())[<NUM_LIT:0>]<EOL><DEDENT>elif len(self._data) > <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(self.v_full_name, str(list(self._data.keys()))))<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>' %<EOL>self.v_full_name)<EOL><DEDENT><DEDENT>result_list = []<EOL>for name in args:<EOL><INDENT>name = self.f_translate_key(name)<EOL>if not name in self._data:<EOL><INDENT>if name == '<STR_LIT:data>' and len(self._data) == <NUM_LIT:1>:<EOL><INDENT>return self._data[list(self._data.keys())[<NUM_LIT:0>]]<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>' %<EOL>(name, self.v_full_name))<EOL><DEDENT><DEDENT>result_list.append(self._data[name])<EOL><DEDENT>if len(args) == <NUM_LIT:1>:<EOL><INDENT>return result_list[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return result_list<EOL><DEDENT>

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 call `f_get()` without arguments.
         If you call `f_get()` and the result contains more than one element a ValueError is
         thrown.

         If the requested item(s) cannot be found an AttributeError is thrown.

        :param args: strings-names or integers

        :return: Single data item or tuple of data

        Example:

        >>> res = Result('supergroup.subgroup.myresult', comment='I am a neat example!' \
        [1000,2000], {'a':'b','c':333}, hitchhiker='Arthur Dent')
        >>> res.f_get('hitchhiker')
        'Arthur Dent'
        >>> res.f_get(0)
        [1000,2000]
        >>> res.f_get('hitchhiker', 'myresult')
        ('Arthur Dent', [1000,2000])


if self.v_stored:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if self._supports(item):<EOL><INDENT>if name in self._data:<EOL><INDENT>self._logger.debug('<STR_LIT>' % (name, self.v_full_name))<EOL><DEDENT>self._data[name] = item<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>' %<EOL>(name, str(type(item))))<EOL><DEDENT>

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 their types are appropriate.

        :param name: The name of the data item

        :param item: The data item

        :raises: TypeError

        Example usage:

        >>> res.f_set_single('answer', 42)
        >>> res.f_get('answer')
        42


return type(item) in Result.SUPPORTED_DATA<EOL>

Checks if outer data structure is supported.


return len(self._data) == <NUM_LIT:1> and self.v_name in self._data<EOL>

Whether or not the result supports fast access.

        A result supports fast access if it contains exactly one item with the name of the result.


store_dict = {}<EOL>store_dict.update(self._data)<EOL>return store_dict<EOL>

Returns a storage dictionary understood by the storage service.

        Simply returns a shallow copy of its own data dictionary.


self._data_ = load_dict<EOL>


for arg in args:<EOL><INDENT>arg = self.f_translate_key(arg)<EOL>if arg in self._data:<EOL><INDENT>del self._data[arg]<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>' % (self.name_, arg))<EOL><DEDENT><DEDENT>


if item[<NUM_LIT:0>] == '<STR_LIT:_>':<EOL><INDENT>super(Result, self).__delattr__(item)<EOL><DEDENT>else:<EOL><INDENT>self.f_remove(item)<EOL><DEDENT>

Deletes an item from the result.

        If the item has been stored to disk before with a storage service, this storage is not
        deleted!

        :param item: Name of item to delete

        :raises: AttributeError if the item does not exist

        Example usage:

        >>> res = Result('Iam.an.example', comment='And a neat one, indeed!', fortytwo=42)
        >>> 'fortytwo' in res
        True
        >>> del res.fortytwo
        >>> 'fortytwo' in res
        False


if SparseParameter._is_supported_matrix(item):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return super(SparseResult, self)._supports(item)<EOL><DEDENT>

Supports everything of parent class and csr, csc, bsr, and dia sparse matrices.


store_dict = {}<EOL>for key in self._data:<EOL><INDENT>val = self._data[key]<EOL>if SparseParameter._is_supported_matrix(val):<EOL><INDENT>data_list, name_list, hash_tuple = SparseParameter._serialize_matrix(val)<EOL>rename_list = ['<STR_LIT>' % (key, SparseParameter.IDENTIFIER, name)<EOL>for name in name_list]<EOL>is_dia = int(len(rename_list) == <NUM_LIT:4>)<EOL>store_dict[key + SparseResult.IDENTIFIER + '<STR_LIT>'] = is_dia<EOL>for idx, name in enumerate(rename_list):<EOL><INDENT>store_dict[name] = data_list[idx]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>store_dict[key] = val<EOL><DEDENT><DEDENT>return store_dict<EOL>

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__`.


for key in list(load_dict.keys()):<EOL><INDENT>if key in load_dict:<EOL><INDENT>if SparseResult.IDENTIFIER in key:<EOL><INDENT>new_key = key.split(SparseResult.IDENTIFIER)[<NUM_LIT:0>]<EOL>is_dia = load_dict.pop(new_key + SparseResult.IDENTIFIER + '<STR_LIT>')<EOL>name_list = SparseParameter._get_name_list(is_dia)<EOL>rename_list = ['<STR_LIT>' % (new_key, SparseResult.IDENTIFIER, name)<EOL>for name in name_list]<EOL>data_list = [load_dict.pop(name) for name in rename_list]<EOL>matrix = SparseParameter._reconstruct_matrix(data_list)<EOL>self._data[new_key] = matrix<EOL><DEDENT>else:<EOL><INDENT>self._data[key] = load_dict[key]<EOL><DEDENT><DEDENT><DEDENT>

Loads data from `load_dict`

        Reconstruction of sparse matrices similar to the :class:`~pypet.parameter.SparseParameter`.


return self._protocol<EOL>

The protocol used to pickle data, default is 0.

        See pickle_ documentation for the protocols.

        .. _pickle: http://docs.python.org/2/library/pickle.html


self._protocol = value<EOL>


if self.v_stored:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if name == PickleResult.PROTOCOL:<EOL><INDENT>raise AttributeError('<STR_LIT>' % PickleResult.PROTOCOL)<EOL><DEDENT>self._data[name] = item<EOL>

Adds a single data item to the pickle result.

         Note that it is NOT checked if the item can be pickled!


store_dict = {}<EOL>for key, val in self._data.items():<EOL><INDENT>store_dict[key] = pickle.dumps(val, protocol=self.v_protocol)<EOL><DEDENT>store_dict[PickleResult.PROTOCOL] = self.v_protocol<EOL>return store_dict<EOL>

Returns a dictionary containing pickle dumps


try:<EOL><INDENT>self.v_protocol = load_dict.pop(PickleParameter.PROTOCOL)<EOL><DEDENT>except KeyError:<EOL><INDENT>dump = next(load_dict.values())<EOL>self.v_protocol = PickleParameter._get_protocol(dump)<EOL><DEDENT>for key in load_dict:<EOL><INDENT>val = load_dict[key]<EOL>self._data[key] = pickle.loads(val)<EOL><DEDENT>

Reconstructs all items from the pickle dumps in `load_dict`.

        Sets the `v_protocol` property to the protocol of the first reconstructed item.


steps = traj.steps<EOL>initial_conditions = traj.initial_conditions<EOL>dimension = len(initial_conditions)<EOL>result_array = np.zeros((steps,dimension))<EOL>func_params_dict = traj.func_params.f_to_dict(short_names=True, fast_access=True)<EOL>result_array[<NUM_LIT:0>] = initial_conditions<EOL>for idx in range(<NUM_LIT:1>,steps):<EOL><INDENT>result_array[idx] = diff_func(result_array[idx-<NUM_LIT:1>], **func_params_dict) * traj.dt +result_array[idx-<NUM_LIT:1>]<EOL><DEDENT>traj.f_add_result('<STR_LIT>', data=result_array, comment='<STR_LIT>')<EOL>

Simulation function for Euler integration.

    :param traj:

        Container for parameters and results

    :param diff_func:

        The differential equation we want to integrate


traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.f_add_parameter(ArrayParameter,'<STR_LIT>', np.array([<NUM_LIT:0.0>,<NUM_LIT:0.0>,<NUM_LIT:0.0>]),<EOL>comment = '<STR_LIT>'<EOL>'<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>)<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/<NUM_LIT>)<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>)<EOL>traj.func_params.v_annotations.info='<STR_LIT>''<STR_LIT>''<STR_LIT>'<EOL>

Adds all necessary parameters to the `traj` container


def diff_lorenz(value_array, sigma, beta, rho):

diff_array = np.zeros(<NUM_LIT:3>)<EOL>diff_array[<NUM_LIT:0>] = sigma * (value_array[<NUM_LIT:1>]-value_array[<NUM_LIT:0>])<EOL>diff_array[<NUM_LIT:1>] = value_array[<NUM_LIT:0>] * (rho - value_array[<NUM_LIT:2>]) - value_array[<NUM_LIT:1>]<EOL>diff_array[<NUM_LIT:2>] = value_array[<NUM_LIT:0>] * value_array[<NUM_LIT:1>] - beta * value_array[<NUM_LIT:2>]<EOL>return diff_array<EOL>

The Lorenz attractor differential equation

    :param value_array: 3d array containing the x,y, and z component values.
    :param sigma: Constant attractor parameter
    :param beta: FConstant attractor parameter
    :param rho: Constant attractor parameter

    :return: 3d array of the Lorenz system evaluated at `value_array`


print('<STR_LIT>' % filename)<EOL>outfilesource = os.path.join(os.getcwd(), filename)<EOL>outfiletarget = '<STR_LIT>' + ADDRESS + WORKING_DIR<EOL>out = saga.filesystem.File(outfilesource, session=session, flags=OVERWRITE)<EOL>out.copy(outfiletarget)<EOL>print('<STR_LIT>' % (filename, outfiletarget))<EOL>


print('<STR_LIT>' % filename)<EOL>infilesource = os.path.join('<STR_LIT>' + ADDRESS + WORKING_DIR,<EOL>filename)<EOL>infiletarget = os.path.join(os.getcwd(), filename)<EOL>incoming = saga.filesystem.File(infilesource, session=session, flags=OVERWRITE)<EOL>incoming.copy(infiletarget)<EOL>print('<STR_LIT>' % (filename, infiletarget))<EOL>


ctx = saga.Context("<STR_LIT>")<EOL>ctx.user_id = USER<EOL>ctx.user_pass = PASSWORD<EOL>session = saga.Session()<EOL>session.add_context(ctx)<EOL>return session<EOL>


jd = saga.job.Description()<EOL>jd.executable      = '<STR_LIT>'<EOL>jd.arguments       = ['<STR_LIT>']<EOL>jd.output          = "<STR_LIT>"<EOL>jd.error           = "<STR_LIT>"<EOL>jd.working_directory = WORKING_DIR<EOL>js = saga.job.Service('<STR_LIT>' + ADDRESS, session=session)<EOL>myjob = js.create_job(jd)<EOL>print("<STR_LIT>")<EOL>myjob.run()<EOL>print("<STR_LIT>" % (myjob.id))<EOL>print("<STR_LIT>" % (myjob.state))<EOL>print("<STR_LIT>")<EOL>myjob.wait()<EOL>print("<STR_LIT>" % (myjob.state))<EOL>print("<STR_LIT>" % (myjob.exit_code))<EOL>

Merges all trajectories found in the working directory


js = saga.job.Service('<STR_LIT>' + ADDRESS, session=session)<EOL>batches = range(<NUM_LIT:3>)<EOL>jobs = []<EOL>for batch in batches:<EOL><INDENT>print('<STR_LIT>' % batch)<EOL>jd = saga.job.Description()<EOL>jd.executable      = '<STR_LIT>'<EOL>jd.arguments       = ['<STR_LIT>' + str(batch)]<EOL>jd.output          = "<STR_LIT>" + str(batch)<EOL>jd.error           = "<STR_LIT>" + str(batch)<EOL>jd.working_directory = WORKING_DIR<EOL>myjob = js.create_job(jd)<EOL>print("<STR_LIT>" % (myjob.id))<EOL>print("<STR_LIT>" % (myjob.state))<EOL>print("<STR_LIT>")<EOL>myjob.run()<EOL>jobs.append(myjob)<EOL><DEDENT>for myjob in jobs:<EOL><INDENT>print("<STR_LIT>" % (myjob.id))<EOL>print("<STR_LIT>" % (myjob.state))<EOL>print("<STR_LIT>")<EOL>myjob.wait()<EOL>print("<STR_LIT>" % (myjob.state))<EOL>print("<STR_LIT>" % (myjob.exit_code))<EOL><DEDENT>

Starts all jobs and runs `the_task.py` in batches.


folder = os.getcwd()<EOL>print('<STR_LIT>')<EOL>merge_all_in_folder(folder,<EOL>delete_other_files=True,  <EOL>dynamic_imports=FunctionParameter,<EOL>backup=False)<EOL>print('<STR_LIT>')<EOL>

Simply merge all trajectories in the working directory


traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.f_add_parameter(ArrayParameter,'<STR_LIT>', np.array([<NUM_LIT:0.1>,<NUM_LIT>,<NUM_LIT>]),<EOL>comment = '<STR_LIT>'<EOL>'<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>)<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/<NUM_LIT>)<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>)<EOL>traj.func_params.v_annotations.info='<STR_LIT>''<STR_LIT>''<STR_LIT>'<EOL>


optlist, args = getopt.getopt(sys.argv[<NUM_LIT:1>:], '<STR_LIT>', longopts='<STR_LIT>')<EOL>batch = <NUM_LIT:0><EOL>for o, a in optlist:<EOL><INDENT>if o == '<STR_LIT>':<EOL><INDENT>batch = int(a)<EOL>print('<STR_LIT>' % batch)<EOL><DEDENT><DEDENT>return batch<EOL>

Function that parses the batch id from the command line arguments


explore_dict = {}<EOL>explore_dict['<STR_LIT>'] = np.arange(<NUM_LIT> * batch, <NUM_LIT>*(batch+<NUM_LIT:1>), <NUM_LIT:1.0>).tolist()<EOL>traj.f_explore(explore_dict)<EOL>

Chooses exploration according to `batch`


<EOL>traj.last_process_name = mp.current_process().name<EOL>traj.results.f_store(store_data=<NUM_LIT:3>)<EOL>

Target function that manipulates the trajectory.

    Stores the current name of the process into the trajectory and
    **overwrites** previous settings.

    :param traj:

        Trajectory container with multiprocessing safe storage service


z=traj.x*traj.y<EOL>traj.f_add_result('<STR_LIT:z>',z=z, comment='<STR_LIT>')<EOL>

Sophisticated simulation of multiplication


<EOL>filename = os.path.join('<STR_LIT>', '<STR_LIT>')<EOL>env = Environment(trajectory='<STR_LIT>',<EOL>filename=filename,<EOL>file_title='<STR_LIT>',<EOL>log_stdout=True,<EOL>comment='<STR_LIT>',<EOL>multiproc=True,<EOL>ncores=<NUM_LIT:4>,<EOL>use_pool=True,  <EOL>freeze_input=True,  <EOL>wrap_mode=pypetconstants.WRAP_MODE_QUEUE,<EOL>graceful_exit=True,  <EOL>overwrite_file=True)<EOL>traj = env.trajectory<EOL>traj.f_add_parameter('<STR_LIT:x>', <NUM_LIT:1.0>, comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT:y>', <NUM_LIT:1.0>, comment='<STR_LIT>')<EOL>traj.f_explore(cartesian_product({'<STR_LIT:x>':[float(x) for x in range(<NUM_LIT:20>)],<EOL>'<STR_LIT:y>':[float(y) for y in range(<NUM_LIT:20>)]}))<EOL>env.run(multiply)<EOL>env.disable_logging()<EOL>

Main function to protect the *entry point* of the program.

    If you want to use multiprocessing under Windows you need to wrap your
    main code creating an environment into a function. Otherwise
    the newly started child processes will re-execute the code and throw
    errors (also see https://docs.python.org/2/library/multiprocessing.html#windows).


explored = False<EOL>for param in traj.f_get_explored_parameters():<EOL><INDENT>if param in group_node:<EOL><INDENT>explored = True<EOL>break<EOL><DEDENT><DEDENT>return explored<EOL>

Checks if one the parameters in `group_node` is explored.

    :param traj: Trajectory container
    :param group_node: Group node
    :return: `True` or `False`


assert(isinstance(traj,Trajectory))<EOL>scale = traj.simulation.scale<EOL>traj.v_standard_parameter = Brian2Parameter<EOL>model_eqs = '''<STR_LIT>'''<EOL>conn_eqs = '''<STR_LIT>'''<EOL>traj.f_add_parameter('<STR_LIT>', model_eqs,<EOL>comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', conn_eqs,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:1>*ms, comment = '<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:3>*ms, comment = '<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:2>*ms, comment = '<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', '<STR_LIT>', comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', '<STR_LIT>',<EOL>comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:5>*ms, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', int(<NUM_LIT>*scale), comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', int(<NUM_LIT>*scale), comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:15>*ms, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:10>*ms, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:1.0>, comment = "<STR_LIT>")<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>, comment = "<STR_LIT>")<EOL>

Adds all neuron group parameters to `traj`.


model_eqs = traj.model.eqs<EOL>post_eqs={}<EOL>for name_post in ['<STR_LIT:i>','<STR_LIT:e>']:<EOL><INDENT>variables_dict ={}<EOL>new_model_eqs=model_eqs.replace('<STR_LIT:POST>', name_post)<EOL>for name_pre in ['<STR_LIT:i>', '<STR_LIT:e>']:<EOL><INDENT>conn_eqs = traj.model.synaptic.eqs<EOL>new_conn_eqs = conn_eqs.replace('<STR_LIT>', name_pre)<EOL>new_model_eqs += new_conn_eqs<EOL>tau1 = traj.model.synaptic['<STR_LIT>']<EOL>tau2 = traj.model.synaptic['<STR_LIT>'+name_pre]<EOL>normalization = (tau1-tau2) / tau2<EOL>invtau1=<NUM_LIT:1.0>/tau1<EOL>invtau2 = <NUM_LIT:1.0>/tau2<EOL>variables_dict['<STR_LIT>'+name_pre] = invtau1<EOL>variables_dict['<STR_LIT>'+name_pre] = invtau2<EOL>variables_dict['<STR_LIT>'+name_pre] = normalization<EOL>variables_dict['<STR_LIT>'+name_pre] = tau1<EOL>variables_dict['<STR_LIT>'+name_pre] = tau2<EOL><DEDENT>variables_dict['<STR_LIT>'+name_post] = traj.model['<STR_LIT>'+name_post]<EOL>post_eqs[name_post] = Equations(new_model_eqs, **variables_dict)<EOL><DEDENT>return post_eqs<EOL>

Computes model equations for the excitatory and inhibitory population.

        Equation objects are created by fusing `model.eqs` and `model.synaptic.eqs`
        and replacing `PRE` by `i` (for inhibitory) or `e` (for excitatory) depending
        on the type of population.

        :return: Dictionary with 'i' equation object for inhibitory neurons and 'e' for excitatory


def pre_build(self, traj, brian_list, network_dict):

self._pre_build = not _explored_parameters_in_group(traj, traj.parameters.model)<EOL>if self._pre_build:<EOL><INDENT>self._build_model(traj, brian_list, network_dict)<EOL><DEDENT>

Pre-builds the neuron groups.

        Pre-build is only performed if none of the
        relevant parameters is explored.

        :param traj: Trajectory container

        :param brian_list:

            List of objects passed to BRIAN network constructor.

            Adds:

            Inhibitory neuron group

            Excitatory neuron group

        :param network_dict:

            Dictionary of elements shared among the components

            Adds:

            'neurons_i': Inhibitory neuron group

            'neurons_e': Excitatory neuron group


def build(self, traj, brian_list, network_dict):

if not hasattr(self, '<STR_LIT>') or not self._pre_build:<EOL><INDENT>self._build_model(traj, brian_list, network_dict)<EOL><DEDENT>

Builds the neuron groups.

        Build is only performed if neuron group was not
        pre-build before.

        :param traj: Trajectory container

        :param brian_list:

            List of objects passed to BRIAN network constructor.

            Adds:

            Inhibitory neuron group

            Excitatory neuron group

        :param network_dict:

            Dictionary of elements shared among the components

            Adds:

            'neurons_i': Inhibitory neuron group

            'neurons_e': Excitatory neuron group


def _build_model(self, traj, brian_list, network_dict):

model = traj.parameters.model<EOL>eqs_dict = self._build_model_eqs(traj)<EOL>eqs_i = eqs_dict['<STR_LIT:i>']<EOL>neurons_i = NeuronGroup(N=model.N_i,<EOL>model = eqs_i,<EOL>threshold=model.V_th,<EOL>reset=model.reset_func,<EOL>refractory=model.refractory,<EOL>method='<STR_LIT>')<EOL>eqs_e = eqs_dict['<STR_LIT:e>']<EOL>neurons_e = NeuronGroup(N=model.N_e,<EOL>model = eqs_e,<EOL>threshold=model.V_th,<EOL>reset=model.reset_func,<EOL>refractory=model.refractory,<EOL>method='<STR_LIT>')<EOL>neurons_e.mu =rand(model.N_e) * (model.mu_e_max - model.mu_e_min) + model.mu_e_min<EOL>neurons_i.mu =rand(model.N_i) * (model.mu_i_max - model.mu_i_min) + model.mu_i_min<EOL>neurons_e.V = rand(model.N_e)<EOL>neurons_i.V = rand(model.N_i)<EOL>brian_list.append(neurons_i)<EOL>brian_list.append(neurons_e)<EOL>network_dict['<STR_LIT>']=neurons_e<EOL>network_dict['<STR_LIT>']=neurons_i<EOL>

Builds the neuron groups from `traj`.

        Adds the neuron groups to `brian_list` and `network_dict`.


assert(isinstance(traj,Trajectory))<EOL>traj.v_standard_parameter = Brian2Parameter<EOL>scale = traj.simulation.scale<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:1.0>, comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:100>, comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>,<EOL>comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>,<EOL>comment='<STR_LIT>' )<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>,<EOL>comment='<STR_LIT>' )<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>,<EOL>comment='<STR_LIT>' )<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT:0.1>,<EOL>comment='<STR_LIT>' )<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/np.sqrt(scale),<EOL>comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/np.sqrt(scale),<EOL>comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/np.sqrt(scale),<EOL>comment='<STR_LIT>')<EOL>traj.f_add_parameter('<STR_LIT>', <NUM_LIT>/np.sqrt(scale),<EOL>comment='<STR_LIT>')<EOL>


self._pre_build = not _explored_parameters_in_group(traj, traj.parameters.connections)<EOL>self._pre_build = (self._pre_build and '<STR_LIT>' in network_dict and<EOL>'<STR_LIT>' in network_dict)<EOL>if self._pre_build:<EOL><INDENT>self._build_connections(traj, brian_list, network_dict)<EOL><DEDENT>

Pre-builds the connections.

        Pre-build is only performed if none of the
        relevant parameters is explored and the relevant neuron groups
        exist.

        :param traj: Trajectory container

        :param brian_list:

            List of objects passed to BRIAN network constructor.

            Adds:

            Connections, amount depends on clustering

        :param network_dict:

            Dictionary of elements shared among the components

            Expects:

            'neurons_i': Inhibitory neuron group

            'neurons_e': Excitatory neuron group

            Adds:

            Connections, amount depends on clustering


if not hasattr(self, '<STR_LIT>') or not self._pre_build:<EOL><INDENT>self._build_connections(traj, brian_list, network_dict)<EOL><DEDENT>

Builds the connections.

        Build is only performed if connections have not
        been pre-build.

        :param traj: Trajectory container

        :param brian_list:

            List of objects passed to BRIAN network constructor.

            Adds:

            Connections, amount depends on clustering

        :param network_dict:

            Dictionary of elements shared among the components

            Expects:

            'neurons_i': Inhibitory neuron group

            'neurons_e': Excitatory neuron group

            Adds:

            Connections, amount depends on clustering


def _build_connections(self, traj, brian_list, network_dict):

connections = traj.connections<EOL>neurons_i = network_dict['<STR_LIT>']<EOL>neurons_e = network_dict['<STR_LIT>']<EOL>print('<STR_LIT>')<EOL>self.conn_ii = Synapses(neurons_i,neurons_i, on_pre='<STR_LIT>' % connections.J_ii)<EOL>self.conn_ii.connect('<STR_LIT>', p=connections.p_ii)<EOL>print('<STR_LIT>')<EOL>self.conn_ei = Synapses(neurons_i,neurons_e, on_pre='<STR_LIT>' % connections.J_ei)<EOL>self.conn_ei.connect('<STR_LIT>', p=connections.p_ei)<EOL>print('<STR_LIT>')<EOL>self.conn_ie = Synapses(neurons_e,neurons_i, on_pre='<STR_LIT>' % connections.J_ie)<EOL>self.conn_ie.connect('<STR_LIT>', p=connections.p_ie)<EOL>conns_list = [self.conn_ii, self.conn_ei, self.conn_ie]<EOL>if connections.R_ee > <NUM_LIT:1.0>:<EOL><INDENT>cluster_list=[]<EOL>cluster_conns_list=[]<EOL>model=traj.model<EOL>clusters = int(model.N_e/connections.clustersize_e)<EOL>traj.f_add_derived_parameter('<STR_LIT>', clusters, comment='<STR_LIT>')<EOL>p_out = (connections.p_ee*model.N_e) /(connections.R_ee*connections.clustersize_e+model.N_e- connections.clustersize_e)<EOL>p_in = p_out * connections.R_ee<EOL>traj.f_add_derived_parameter('<STR_LIT>', p_in ,<EOL>comment='<STR_LIT>')<EOL>traj.f_add_derived_parameter('<STR_LIT>', p_out ,<EOL>comment='<STR_LIT>')<EOL>low_index = <NUM_LIT:0><EOL>high_index = connections.clustersize_e<EOL>for irun in range(clusters):<EOL><INDENT>cluster = neurons_e[low_index:high_index]<EOL>print('<STR_LIT>' % (irun, clusters))<EOL>conn = Synapses(cluster,cluster,<EOL>on_pre='<STR_LIT>' % (connections.J_ee*connections.strength_factor))<EOL>conn.connect('<STR_LIT>', p=p_in)<EOL>cluster_conns_list.append(conn)<EOL>if low_index > <NUM_LIT:0>:<EOL><INDENT>rest_low = neurons_e[<NUM_LIT:0>:low_index]<EOL>print('<STR_LIT>')<EOL>low_conn = Synapses(cluster,rest_low,<EOL>on_pre='<STR_LIT>' % connections.J_ee)<EOL>low_conn.connect('<STR_LIT>', p=p_out)<EOL>cluster_conns_list.append(low_conn)<EOL><DEDENT>if high_index < model.N_e:<EOL><INDENT>rest_high = neurons_e[high_index:model.N_e]<EOL>print('<STR_LIT>')<EOL>high_conn = Synapses(cluster,rest_high,<EOL>on_pre='<STR_LIT>' % connections.J_ee)<EOL>high_conn.connect('<STR_LIT>', p=p_out)<EOL>cluster_conns_list.append(high_conn)<EOL><DEDENT>low_index=high_index<EOL>high_index+=connections.clustersize_e<EOL><DEDENT>self.cluster_conns=cluster_conns_list<EOL>conns_list+=cluster_conns_list<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>self.conn_ee = Synapses(neurons_e,neurons_e,<EOL>on_pre='<STR_LIT>' % connections.J_ee)<EOL>self.conn_ee.connect('<STR_LIT>', p=connections.p_ee)<EOL>conns_list.append(self.conn_ee)<EOL><DEDENT>brian_list.extend(conns_list)<EOL>network_dict['<STR_LIT>'] = conns_list<EOL>

Connects neuron groups `neurons_i` and `neurons_e`.

        Adds all connections to `brian_list` and adds a list of connections
        with the key 'connections' to the `network_dict`.


Adds all necessary parameters to `traj` container.


@staticmethod<EOL><INDENT>def _compute_fano_factor(spike_res, neuron_id, time_window, start_time, end_time):<DEDENT>

assert(end_time >= start_time+time_window)<EOL>bins = (end_time-start_time)/time_window<EOL>bins = int(np.floor(bins))<EOL>binned_spikes = np.zeros(bins)<EOL>spike_array_neuron = spike_res.t[spike_res.i==neuron_id]<EOL>for bin in range(bins):<EOL><INDENT>lower_time = start_time+time_window*bin<EOL>upper_time = start_time+time_window*(bin+<NUM_LIT:1>)<EOL>spike_array_interval = spike_array_neuron[spike_array_neuron >= lower_time]<EOL>spike_array_interval = spike_array_interval[spike_array_interval < upper_time]<EOL>spikes = len(spike_array_interval)<EOL>binned_spikes[bin]=spikes<EOL><DEDENT>var = np.var(binned_spikes)<EOL>avg = np.mean(binned_spikes)<EOL>if avg > <NUM_LIT:0>:<EOL><INDENT>return var/float(avg)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>

Computes Fano Factor for one neuron.

        :param spike_res:

            Result containing the spiketimes of all neurons

        :param neuron_id:

            Index of neuron for which FF is computed

        :param time_window:

            Length of the consecutive time windows to compute the FF

        :param start_time:

            Start time of measurement to consider

        :param end_time:

            End time of measurement to consider

        :return:

            Fano Factor (float) or
            returns 0 if mean firing activity is 0.


@staticmethod<EOL><INDENT>def _compute_mean_fano_factor( neuron_ids, spike_res, time_window, start_time, end_time):<DEDENT>

ffs = np.zeros(len(neuron_ids))<EOL>for idx, neuron_id in enumerate(neuron_ids):<EOL><INDENT>ff=CNFanoFactorComputer._compute_fano_factor(<EOL>spike_res, neuron_id, time_window, start_time, end_time)<EOL>ffs[idx]=ff<EOL><DEDENT>mean_ff = np.mean(ffs)<EOL>return mean_ff<EOL>

Computes average Fano Factor over many neurons.

        :param neuron_ids:

            List of neuron indices to average over

        :param spike_res:

            Result containing all the spikes

        :param time_window:

            Length of the consecutive time windows to compute the FF

        :param start_time:

            Start time of measurement to consider

        :param end_time:

            End time of measurement to consider

        :return:

            Average fano factor


def analyse(self, traj, network, current_subrun, subrun_list, network_dict):

<EOL>if len(subrun_list)==<NUM_LIT:0>:<EOL><INDENT>spikes_e = traj.results.monitors.spikes_e<EOL>time_window = traj.parameters.analysis.statistics.time_window<EOL>start_time = traj.parameters.simulation.durations.initial_run<EOL>end_time = start_time+traj.parameters.simulation.durations.measurement_run<EOL>neuron_ids = traj.parameters.analysis.statistics.neuron_ids<EOL>mean_ff = self._compute_mean_fano_factor(<EOL>neuron_ids, spikes_e, time_window, start_time, end_time)<EOL>traj.f_add_result('<STR_LIT>', mean_ff, comment='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>print('<STR_LIT>' % (traj.R_ee, mean_ff))<EOL><DEDENT>

Calculates average Fano Factor of a network.

        :param traj:

            Trajectory container

            Expects:

            `results.monitors.spikes_e`: Data from SpikeMonitor for excitatory neurons

            Adds:

            `results.statistics.mean_fano_factor`: Average Fano Factor

        :param network:

            The BRIAN network

        :param current_subrun:

            BrianParameter

        :param subrun_list:

            Upcoming subruns, analysis is only performed if subruns is empty,
            aka the final subrun has finished.

        :param network_dict:

            Dictionary of items shared among componetns


def add_to_network(self, traj, network, current_subrun, subrun_list, network_dict):

if current_subrun.v_annotations.order == <NUM_LIT:1>:<EOL><INDENT>self._add_monitors(traj, network, network_dict)<EOL><DEDENT>

Adds monitors to the network if the measurement run is carried out.

        :param traj: Trajectory container

        :param network: The BRIAN network

        :param current_subrun: BrianParameter

        :param subrun_list: List of coming subrun_list

        :param network_dict:

            Dictionary of items shared among the components

            Expects:

            'neurons_e': Excitatory neuron group

            Adds:

            'monitors': List of monitors

                0. SpikeMonitor of excitatory neurons

                1. StateMonitor of membrane potential of some excitatory neurons
                (specified in `neuron_records`)

                2. StateMonitor of excitatory synaptic currents of some excitatory neurons

                3. State monitor of inhibitory currents of some excitatory neurons