def execute_network_run(self, traj, network, network_dict, component_list, analyser_list):

self._execute_network_run(traj, network, network_dict, component_list, analyser_list,<EOL>pre_run=False)<EOL>

Runs a network in an experimental run.

        Called by a :class:`~pypet.brian2.network.NetworkManager`.

        A network run is divided into several subruns which are defined as
        :class:`~pypet.brian2.parameter.Brian2Parameter` instances.

        These subruns are extracted from the trajectory. All
        :class:`~pypet.brian2.parameter.Brian2Parameter` instances found under
        `traj.parameters.simulation.durations` (default, you can change the
        name of the group where to search for durations at runner initialisation).
        The order is determined from
        the `v_annotations.order` attributes. An error is thrown if no orders attribute
        can be found or if two parameters have the same order.

        There must be at least one subrun in the trajectory,
        otherwise an AttributeError is thrown. If two subruns equal in their order
        property a RuntimeError is thrown.

        For every subrun the following steps are executed:

        1.  Calling :func:`~pypet.brian2.network.NetworkComponent.add_to_network` for every
            every :class:`~pypet.brian2.network.NetworkComponent` in the order as
            they were passed to the :class:`~pypet.brian2.network.NetworkManager`.

        2.  Calling :func:`~pypet.brian2.network.NetworkComponent.add_to_network` for every
            every :class:`~pypet.brian2.network.NetworkAnalyser` in the order as
            they were passed to the :class:`~pypet.brian2.network.NetworkManager`.

        3.  Calling :func:`~pypet.brian2.network.NetworkComponent.add_to_network` of the
            NetworkRunner itself (usually the network runner should not add or remove
            anything from the network, but this step is executed for completeness).

        4.  Running the BRIAN2 network for the duration of the current subrun by calling
            the network's `run` function.

        5.  Calling :func:`~pypet.brian2.network.NetworkAnalyser.analyse` for every
            every :class:`~pypet.brian2.network.NetworkAnalyser` in the order as
            they were passed to the :class:`~pypet.brian2.network.NetworkManager`.

        6.  Calling :func:`~pypet.brian2.network.NetworkComponent.remove_from_network` of the
            NetworkRunner itself (usually the network runner should not add or remove
            anything from the network, but this step is executed for completeness).

        7.  Calling :func:`~pypet.brian2.network.NetworkComponent.remove_from_network` for every
            every :class:`~pypet.brian2.network.NetworkAnalyser` in the order as
            they were passed to the :class:`~pypet.brian2.network.NetworkManager`

        8.  Calling :func:`~pypet.brian2.network.NetworkComponent.remove_from_network` for every
            every :class:`~pypet.brian2.network.NetworkComponent` in the order as
            they were passed to the :class:`~pypet.brian2.network.NetworkManager`.

        These 8 steps are repeated for every subrun in the `subrun_list`.
        The `subrun_list` passed to all `add_to_network`, `analyse` and
        `remove_from_network` methods can be modified
        within these functions to potentially alter the order of execution or
        even erase or add upcoming subruns if necessary.

        For example, a NetworkAnalyser checks
        for epileptic pathological activity and cancels all coming subruns in case
        of undesired network dynamics.

        :param traj: Trajectory container

        :param network: BRIAN2 network

        :param network_dict: Dictionary of items shared among all components

        :param component_list: List of :class:`~pypet.brian2.network.NetworkComponent` objects

        :param analyser_list: List of :class:`~pypet.brian2.network.NetworkAnalyser` objects


def _extract_subruns(self, traj, pre_run=False):

if pre_run:<EOL><INDENT>durations_list = traj.f_get_all(self._pre_durations_group_name)<EOL><DEDENT>else:<EOL><INDENT>durations_list = traj.f_get_all(self._durations_group_name)<EOL><DEDENT>subruns = {}<EOL>orders = []<EOL>for durations in durations_list:<EOL><INDENT>for duration_param in durations.f_iter_leaves(with_links=False):<EOL><INDENT>if '<STR_LIT>' in duration_param.v_annotations:<EOL><INDENT>order = duration_param.v_annotations.order<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>duration_param.v_full_name)<EOL><DEDENT>if order in subruns:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>' % order)<EOL><DEDENT>else:<EOL><INDENT>subruns[order] = duration_param<EOL>orders.append(order)<EOL><DEDENT><DEDENT><DEDENT>return [subruns[order] for order in sorted(orders)]<EOL>

Extracts subruns from the trajectory.

        :param traj: Trajectory container

        :param pre_run: Boolean whether current run is regular or a pre-run

        :raises: RuntimeError if orders are duplicates or even missing


def _execute_network_run(self, traj, network, network_dict, component_list,<EOL>analyser_list, pre_run=False):

<EOL>subrun_list = self._extract_subruns(traj, pre_run=pre_run)<EOL>subrun_number = <NUM_LIT:0><EOL>while len(subrun_list) > <NUM_LIT:0>:<EOL><INDENT>current_subrun = subrun_list.pop(<NUM_LIT:0>)<EOL>for component in component_list:<EOL><INDENT>component.add_to_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL><DEDENT>for analyser in analyser_list:<EOL><INDENT>analyser.add_to_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL><DEDENT>self.add_to_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL>self._logger.info('<STR_LIT>' %<EOL>(current_subrun.v_name, subrun_number, str(current_subrun.f_get())))<EOL>network.run(duration=current_subrun.f_get(), report=self._report,<EOL>report_period=self._report_period)<EOL>for analyser in analyser_list:<EOL><INDENT>analyser.analyse(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL><DEDENT>self.remove_from_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL>for analyser in analyser_list:<EOL><INDENT>analyser.remove_from_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL><DEDENT>for component in component_list:<EOL><INDENT>component.remove_from_network(traj, network, current_subrun, subrun_list,<EOL>network_dict)<EOL><DEDENT>subrun_number += <NUM_LIT:1><EOL><DEDENT>

Generic `execute_network_run` function, handles experimental runs as well as pre-runs.

        See also :func:`~pypet.brian2.network.NetworkRunner.execute_network_run` and
         :func:`~pypet.brian2.network.NetworkRunner.execute_network_pre_run`.


self._logger.info('<STR_LIT>')<EOL>for component in self.components:<EOL><INDENT>component.add_parameters(traj)<EOL><DEDENT>if self.analysers:<EOL><INDENT>self._logger.info('<STR_LIT>')<EOL>for analyser in self.analysers:<EOL><INDENT>analyser.add_parameters(traj)<EOL><DEDENT><DEDENT>self._logger.info('<STR_LIT>')<EOL>self.network_runner.add_parameters(traj)<EOL>

Adds parameters for a network simulation.

        Calls :func:`~pypet.brian2.network.NetworkComponent.add_parameters` for all components,
        analyser, and the network runner (in this order).

        :param traj:  Trajectory container


self._logger.info('<STR_LIT>')<EOL>for component in self.components:<EOL><INDENT>component.pre_build(traj, self._brian_list, self._network_dict)<EOL><DEDENT>if self.analysers:<EOL><INDENT>self._logger.info('<STR_LIT>')<EOL>for analyser in self.analysers:<EOL><INDENT>analyser.pre_build(traj, self._brian_list, self._network_dict)<EOL><DEDENT><DEDENT>self._logger.info('<STR_LIT>')<EOL>self.network_runner.pre_build(traj, self._brian_list, self._network_dict)<EOL>self._pre_built = True<EOL>

Pre-builds network components.

        Calls :func:`~pypet.brian2.network.NetworkComponent.pre_build` for all components,
        analysers, and the network runner.

        `pre_build` is not automatically called but either needs to be executed manually
        by the user, either calling it directly or by using
        :func:`~pypet.brian2.network.NetworkManager.pre_run`.

        This function does not create a `BRIAN2 network`, but only it's components.

        :param traj: Trajectory container


self._logger.info('<STR_LIT>')<EOL>for component in self.components:<EOL><INDENT>component.build(traj, self._brian_list, self._network_dict)<EOL><DEDENT>if self.analysers:<EOL><INDENT>self._logger.info('<STR_LIT>')<EOL>for analyser in self.analysers:<EOL><INDENT>analyser.build(traj, self._brian_list, self._network_dict)<EOL><DEDENT><DEDENT>self._logger.info('<STR_LIT>')<EOL>self.network_runner.build(traj, self._brian_list, self._network_dict)<EOL>

Pre-builds network components.

        Calls :func:`~pypet.brian2.network.NetworkComponent.build` for all components,
        analysers and the network runner.

        `build` does not need to be called by the user. If `~pypet.brian2.network.run_network`
        is passed to an :class:`~pypet.environment.Environment` with this Network manager,
        `build` is automatically called for each individual experimental run.

        :param traj: Trajectory container


self.pre_build(traj)<EOL>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self._network = self._network_constructor(*self._brian_list)<EOL>self.network_runner.execute_network_pre_run(traj, self._network, self._network_dict,<EOL>self.components, self.analysers)<EOL>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self._pre_run = True<EOL>if hasattr(self._network, '<STR_LIT:store>'):<EOL><INDENT>self._network.store('<STR_LIT>')<EOL><DEDENT>

Starts a network run before the individual run.

        Useful if a network needs an initial run that can be shared by all individual
        experimental runs during parameter exploration.

        Needs to be called by the user. If `pre_run_network` is started by the user,
        :func:`~pypet.brian2.network.NetworkManager.pre_build` will be automatically called
        from this function.

        This function will create a new BRIAN2 network which is run by
        the :class:`~pypet.brian2.network.NetworkRunner` and it's
        :func:`~pypet.brian2.network.NetworkRunner.execute_network_pre_run`.

        To see how a network run is structured also take a look at
        :func:`~pypet.brian2.network.NetworkRunner.run_network`.

        :param traj: Trajectory container


<EOL>if self._pre_built:<EOL><INDENT>if self._pre_run and hasattr(self._network, '<STR_LIT>'):<EOL><INDENT>self._network.restore('<STR_LIT>')<EOL>self._network.store('<STR_LIT>')<EOL><DEDENT>self._run_network(traj)<EOL><DEDENT>else:<EOL><INDENT>self._run_network(traj)<EOL><DEDENT>

Top-level simulation function, pass this to the environment

        Performs an individual network run during parameter exploration.

        `run_network` does not need to be called by the user. If this
        method (not this one of the NetworkManager)
        is passed to an :class:`~pypet.environment.Environment` with this NetworkManager,
        `run_network` and :func:`~pypet.brian2.network.NetworkManager.build`
        are automatically called for each individual experimental run.

        This function will create a new BRIAN2 network in case one was not pre-run.
        The execution of the network run is carried out by
        the :class:`~pypet.brian2.network.NetworkRunner` and it's
        :func:`~pypet.brian2.network.NetworkRunner.execute_network_run` (also take
        a look at this function's documentation to see the structure of a network run).

        :param traj: Trajectory container


self.build(traj)<EOL>self._pretty_print_explored_parameters(traj)<EOL>if not self._pre_run:<EOL><INDENT>self._network = self._network_constructor(*self._brian_list)<EOL><DEDENT>self.network_runner.execute_network_run(traj, self._network, self._network_dict,<EOL>self.components, self.analysers)<EOL>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>

Starts a single run carried out by a NetworkRunner.

        Called from the public function :func:`~pypet.brian2.network.NetworkManger.run_network`.

        :param traj: Trajectory container


return Quantity.with_dimensions(<NUM_LIT:1>, get_dimensions(x))<EOL>

Return a `Quantity` with value 1 and the same dimensions.


if expr == '<STR_LIT:1>':<EOL><INDENT>return get_unit_fast(<NUM_LIT:1>)<EOL><DEDENT>elif isinstance(expr, str):<EOL><INDENT>mod = ast.parse(expr, mode='<STR_LIT>')<EOL>expr = mod.body<EOL>return unit_from_expression(expr)<EOL><DEDENT>elif expr.__class__ is ast.Name:<EOL><INDENT>return ALLUNITS[expr.id]<EOL><DEDENT>elif expr.__class__ is ast.Num:<EOL><INDENT>return expr.n<EOL><DEDENT>elif expr.__class__ is ast.UnaryOp:<EOL><INDENT>op = expr.op.__class__.__name__<EOL>operand = unit_from_expression(expr.operand)<EOL>if op=='<STR_LIT>':<EOL><INDENT>return -operand<EOL><DEDENT>else:<EOL><INDENT>raise SyntaxError("<STR_LIT>"+op)<EOL><DEDENT><DEDENT>elif expr.__class__ is ast.BinOp:<EOL><INDENT>op = expr.op.__class__.__name__<EOL>left = unit_from_expression(expr.left)<EOL>right = unit_from_expression(expr.right)<EOL>if op=='<STR_LIT>':<EOL><INDENT>u = left+right<EOL><DEDENT>elif op=='<STR_LIT>':<EOL><INDENT>u = left-right<EOL><DEDENT>elif op=='<STR_LIT>':<EOL><INDENT>u = left*right<EOL><DEDENT>elif op=='<STR_LIT>':<EOL><INDENT>u = left/right<EOL><DEDENT>elif op=='<STR_LIT>':<EOL><INDENT>n = unit_from_expression(expr.right)<EOL>u = left**n<EOL><DEDENT>elif op=='<STR_LIT>':<EOL><INDENT>u = left % right<EOL><DEDENT>else:<EOL><INDENT>raise SyntaxError("<STR_LIT>"+op)<EOL><DEDENT>return u<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>

Takes a unit string like ``'1. * volt'`` and returns the BRIAN2 unit.


if isinstance(data, Quantity):<EOL><INDENT>return True<EOL><DEDENT>elif super(Brian2Parameter, self).f_supports(data):<EOL><INDENT>return True<EOL><DEDENT>return False<EOL>


if isinstance(data, Quantity):<EOL><INDENT>return True<EOL><DEDENT>elif super(Brian2Result, self)._supports(data):<EOL><INDENT>return True<EOL><DEDENT>return False<EOL>


return self._monitor_type<EOL>

The type of the stored monitor. Each MonitorResult can only manage a single Monitor.


if type(item) in [SpikeMonitor, StateMonitor, PopulationRateMonitor]:<EOL><INDENT>if self.v_stored:<EOL><INDENT>self._logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._extract_monitor_data(item)<EOL><DEDENT>else:<EOL><INDENT>super(Brian2MonitorResult, self).f_set_single(name, item)<EOL><DEDENT>

To add a monitor use `f_set_single('monitor', brian_monitor)`.

        Otherwise `f_set_single` works similar to :func:`~pypet.parameter.Result.f_set_single`.


sys.__stderr__.write(text + '<STR_LIT:\n>')<EOL>


return logging.getLogger()<EOL>


return testParams['<STR_LIT>']<EOL>


return rename_log_file(generic_log_folder, trajectory=traj, process_name=process_name)<EOL>

Returns the path to the log files based on trajectory name etc.


url = port_to_tcp()<EOL>errwrite('<STR_LIT>' % url)<EOL>return url<EOL>

Determines the local server url with a random port


conf = testParams['<STR_LIT>']<EOL>pypet_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '<STR_LIT>'))<EOL>init_path = os.path.join(pypet_path, '<STR_LIT>')<EOL>if conf == '<STR_LIT:test>':<EOL><INDENT>conf_file = os.path.join(init_path, '<STR_LIT>')<EOL>conf_parser = handle_config_file(conf_file)<EOL>conf = conf_parser<EOL><DEDENT>elif conf == '<STR_LIT>':<EOL><INDENT>conf_file = os.path.join(init_path, '<STR_LIT>')<EOL>conf_parser = handle_config_file(conf_file)<EOL>conf = conf_parser<EOL><DEDENT>testParams['<STR_LIT>'] = conf<EOL>

Prepares the test logging init files and creates parsers.


global generic_log_folder<EOL>if not filename.startswith('<STR_LIT>'):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>temp_folder = make_temp_dir('<STR_LIT>')<EOL>filename = filename.replace('<STR_LIT>', '<STR_LIT>')<EOL>filename = os.path.join(temp_folder, filename)<EOL>filename = os.path.normpath(filename)<EOL>if generic_log_folder is None:<EOL><INDENT>generic_log_folder = os.path.dirname(filename)<EOL><DEDENT>return filename<EOL>

Replaces the $temp$ wildcard in a filename


parser = cp.ConfigParser()<EOL>parser.read(config_file)<EOL>sections = parser.sections()<EOL>for section in sections:<EOL><INDENT>options = parser.options(section)<EOL>for option in options:<EOL><INDENT>arg = parser.get(section, option, raw=True)<EOL>if '<STR_LIT>' in arg:<EOL><INDENT>LoggingManager._check_and_replace_parser_args(parser, section, option,<EOL>rename_func=_rename_filename,<EOL>make_dirs=False)<EOL><DEDENT><DEDENT><DEDENT>return parser<EOL>

Searches for the $temp wildcard in a given config file and replaces it.


try:<EOL><INDENT>if ((testParams['<STR_LIT>'] is not None and testParams['<STR_LIT>'] != '<STR_LIT>') and<EOL>testParams['<STR_LIT>'] == '<STR_LIT>'):<EOL><INDENT>testParams['<STR_LIT>'] = testParams['<STR_LIT>']<EOL><DEDENT>if not os.path.isdir(testParams['<STR_LIT>']):<EOL><INDENT>os.makedirs(testParams['<STR_LIT>'])<EOL><DEDENT>return os.path.join(testParams['<STR_LIT>'], filename)<EOL><DEDENT>except OSError as exc:<EOL><INDENT>actual_tempdir = os.path.join(tempfile.gettempdir(), testParams['<STR_LIT>'])<EOL>if signal:<EOL><INDENT>errwrite('<STR_LIT>'<EOL>'<STR_LIT>' % actual_tempdir)<EOL><DEDENT>testParams['<STR_LIT>'] = actual_tempdir<EOL>if not os.path.isdir(testParams['<STR_LIT>']):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(testParams['<STR_LIT>'])<EOL><DEDENT>except Exception:<EOL><INDENT>pass <EOL><DEDENT><DEDENT>return os.path.join(actual_tempdir, filename)<EOL><DEDENT>except:<EOL><INDENT>get_root_logger().error('<STR_LIT>')<EOL>raise<EOL><DEDENT>

Creates a temporary folder and returns the joined filename


def run_suite(remove=None, folder=None, suite=None):

if remove is not None:<EOL><INDENT>testParams['<STR_LIT>'] = remove<EOL><DEDENT>testParams['<STR_LIT>'] = folder<EOL>prepare_log_config()<EOL>make_temp_dir('<STR_LIT>', signal=True)<EOL>success = False<EOL>try:<EOL><INDENT>if suite is None:<EOL><INDENT>unittest.main(verbosity=<NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>runner = unittest.TextTestRunner(verbosity=<NUM_LIT:2>)<EOL>result = runner.run(suite)<EOL>success = result.wasSuccessful()<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>remove_data()<EOL><DEDENT>if not success:<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Runs a particular test suite or simply unittest.main.

    Takes care that all temporary data in `folder` is removed if `remove=True`.


global testParams<EOL>if testParams['<STR_LIT>']:<EOL><INDENT>get_root_logger().log(<NUM_LIT>, '<STR_LIT>')<EOL>shutil.rmtree(testParams['<STR_LIT>'], True)<EOL><DEDENT>


opt_list, _ = getopt.getopt(sys.argv[<NUM_LIT:1>:],'<STR_LIT:k>',['<STR_LIT>', '<STR_LIT>'])<EOL>opt_dict = {}<EOL>for opt, arg in opt_list:<EOL><INDENT>if opt == '<STR_LIT>':<EOL><INDENT>opt_dict['<STR_LIT>'] = False<EOL>errwrite('<STR_LIT>')<EOL><DEDENT>if opt == '<STR_LIT>':<EOL><INDENT>opt_dict['<STR_LIT>'] = arg<EOL>errwrite('<STR_LIT>' % arg)<EOL><DEDENT>if opt == '<STR_LIT>':<EOL><INDENT>opt_dict['<STR_LIT>'] = arg<EOL>errwrite('<STR_LIT>' % arg)<EOL><DEDENT><DEDENT>sys.argv = [sys.argv[<NUM_LIT:0>]]<EOL>return opt_dict<EOL>

Parses arguments and returns a dictionary


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

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


flat_dict = flatten_dictionary(param_dict,'<STR_LIT:.>')<EOL>for key, val in flat_dict.items():<EOL><INDENT>if isinstance(val, (np.ndarray, tuple)) or (isinstance(val, list) and<EOL>(len(val) < <NUM_LIT:4> or val[<NUM_LIT:3>] != ())):<EOL><INDENT>traj.f_add_parameter(ArrayParameter,key,val, comment='<STR_LIT>')<EOL><DEDENT>elif isinstance(val, (str,bool,float, int)):<EOL><INDENT>traj.f_add_parameter(Parameter,key,val, comment='<STR_LIT>')<EOL><DEDENT>elif spsp.isspmatrix(val):<EOL><INDENT>traj.f_add_parameter(SparseParameter,key,val, comment='<STR_LIT>').v_annotations.f_set(<EOL>**{'<STR_LIT:Name>':key,'<STR_LIT>' :str(val),'<STR_LIT>':[<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>],<EOL>'<STR_LIT>':np.array([<NUM_LIT>,<NUM_LIT>])})<EOL><DEDENT>elif isinstance(val,list):<EOL><INDENT>traj.f_add_parameter(PickleParameter,key,val, comment='<STR_LIT>', protocol=val[-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>' % (str(val),str(type(val))))<EOL><DEDENT><DEDENT>traj.f_add_derived_parameter('<STR_LIT>', '<STR_LIT>', comment='<STR_LIT>')<EOL>traj.f_add_derived_parameter('<STR_LIT>', '<STR_LIT>', comment='<STR_LIT>')<EOL>traj.f_add_derived_parameter('<STR_LIT>', '<STR_LIT>', comment='<STR_LIT>')<EOL>traj.f_add_derived_parameter('<STR_LIT>', '<STR_LIT>', comment='<STR_LIT>')<EOL>traj.f_add_result('<STR_LIT>',np.str(['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>']),<EOL>comment='<STR_LIT>',)<EOL>traj.results.f_add_leaf('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.f_add_group('<STR_LIT>', comment='<STR_LIT>')<EOL>traj.dpar.f_add_leaf('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.derived_parameters.f_add_leaf('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>traj.par.f_add_leaf('<STR_LIT>', <NUM_LIT>, comment='<STR_LIT>')<EOL>for irun in range(<NUM_LIT>):<EOL><INDENT>traj.f_add_leaf('<STR_LIT>' % irun, <NUM_LIT>, comment='<STR_LIT:f>')<EOL><DEDENT>traj.par.f_add_group('<STR_LIT>', comment='<STR_LIT>')<EOL>traj.f_add_group('<STR_LIT>', comment='<STR_LIT>')<EOL>traj.imgeneric.f_add_leaf('<STR_LIT>', '<STR_LIT>', comment='<STR_LIT>')<EOL>


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

Deletes all handlers and closes all log-files


with open(filename, mode='<STR_LIT:r>') as fh:<EOL><INDENT>file_text = fh.read()<EOL><DEDENT>import_matplotlib = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>new_filename = '<STR_LIT>' + filename<EOL>with open(new_filename, mode='<STR_LIT:w>') as fh:<EOL><INDENT>fh.write(import_matplotlib)<EOL>fh.write(file_text)<EOL><DEDENT>return new_filename<EOL>

Writes a new python file and prepends the a matplotlib import.

    This avoids opening the plots within the test suite


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

Executes a file as script.

    First prepends matplotlib import


if hasattr(os, '<STR_LIT>'):<EOL><INDENT>return nice<EOL><DEDENT>elif psutil is not None:<EOL><INDENT>return psutil.ABOVE_NORMAL_PRIORITY_CLASS<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>


eqs = '''<STR_LIT>'''<EOL>group = NeuronGroup(<NUM_LIT:100>, model=eqs, threshold='<STR_LIT>',<EOL>reset='<STR_LIT>', refractory=<NUM_LIT:5>*ms)<EOL>group.v0 = traj.par.v0<EOL>group.v = np.random.rand(<NUM_LIT:100>) * <NUM_LIT> * mV<EOL>syn = Synapses(group, group, on_pre='<STR_LIT>')<EOL>syn.connect('<STR_LIT>', p=<NUM_LIT>)<EOL>spike_monitor = SpikeMonitor(group, variables=['<STR_LIT:v>'])<EOL>voltage_monitor = StateMonitor(group, '<STR_LIT:v>', record=True)<EOL>pop_monitor = PopulationRateMonitor(group, name='<STR_LIT>' + str(traj.v_idx))<EOL>net = Network(group, syn, spike_monitor, voltage_monitor, pop_monitor)<EOL>net.run(<NUM_LIT>*second, report='<STR_LIT:text>')<EOL>traj.f_add_result(Brian2MonitorResult, '<STR_LIT>',<EOL>spike_monitor)<EOL>traj.f_add_result(Brian2MonitorResult, '<STR_LIT:v>',<EOL>voltage_monitor)<EOL>traj.f_add_result(Brian2MonitorResult, '<STR_LIT>',<EOL>pop_monitor)<EOL>

Runs brian network consisting of
        200 inhibitory IF neurons


<EOL>idx, lock, filename = args<EOL>client_id = '<STR_LIT>'<EOL>try:<EOL><INDENT>random.seed()<EOL>sleep_time = random.uniform(<NUM_LIT:0.0>, <NUM_LIT>)  <EOL>lock.start()<EOL>client_id = str(lock._get_id())<EOL>sidx = '<STR_LIT::>' + client_id + '<STR_LIT::>' + str(idx) +'<STR_LIT:\n>'<EOL>lock.acquire()<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL><DEDENT>lock.release()<EOL>time.sleep(sleep_time / <NUM_LIT>)<EOL>lock.acquire()<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL><DEDENT>lock.release()<EOL>time.sleep(sleep_time * <NUM_LIT>)<EOL>lock.acquire()<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL><DEDENT>lock.release()<EOL>time.sleep(sleep_time)<EOL>lock.acquire()<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time / <NUM_LIT>)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time * <NUM_LIT>)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time / <NUM_LIT>)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time / <NUM_LIT>)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>time.sleep(sleep_time / <NUM_LIT>)<EOL>with open(filename, mode='<STR_LIT:a>') as fh:<EOL><INDENT>fh.write('<STR_LIT>' + sidx)<EOL>flush_and_sync(fh)<EOL><DEDENT>lock.release()<EOL><DEDENT>except:<EOL><INDENT>logging.getLogger().exception('<STR_LIT>' % (idx, client_id))<EOL><DEDENT>

Simple job executed in parallel

    Just sleeps randomly and prints to console.
    Capital letter signal parallel printing


return False<EOL>

Normally the file is opened and closed after each insertion.

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


return False<EOL>

Usually storage services are not supposed to be multiprocessing safe


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

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

See :class:`pypet.storageservice.HDF5StorageService` for an example of an
        implementation and requirements for the API.

        ABSTRACT: Needs to be defined in subclass


def load(self, msg, stuff_to_load, *args, **kwargs):


pass<EOL>

Swallows all arguments for easier debugging


pass<EOL>


pass<EOL>

Do whatever you want, I won't store anything!


if not self.active:<EOL><INDENT>return<EOL><DEDENT>self._updates += <NUM_LIT:1><EOL>current_time = time.time()<EOL>dt = current_time - self._last_time<EOL>if dt > self._display_time:<EOL><INDENT>dfullt = current_time - self._start_time<EOL>seconds = int(dfullt) % <NUM_LIT><EOL>minutes = int(dfullt) / <NUM_LIT><EOL>if minutes == <NUM_LIT:0>:<EOL><INDENT>formatted_time = '<STR_LIT>' % seconds<EOL><DEDENT>else:<EOL><INDENT>formatted_time = '<STR_LIT>' % (minutes, seconds)<EOL><DEDENT>nodespersecond = self._updates / dfullt<EOL>message = '<STR_LIT>' %(self._updates, formatted_time, nodespersecond)<EOL>self._logger.info(message)<EOL>self._last_time = current_time<EOL><DEDENT>

Signals the process timer.

        If more time than the display time has passed a message is emitted.


return self._hdf5file is not None and self._hdf5file.isopen<EOL>


return self._encoding<EOL>


return self._display_time<EOL>

Time interval in seconds, when to display the storage or loading of nodes


return self._complib<EOL>


return self._complevel<EOL>


return self._fletcher32<EOL>


return self._shuffle<EOL>

Whether shuffle filtering should be used


return self._pandas_format<EOL>

Format of pandas data. Applicable formats are 'table' (or 't') and 'fixed' (or 'f')


return self._filename<EOL>

The name and path of the underlying hdf5 file.


if self._overview_group_ is None:<EOL><INDENT>self._overview_group_ = self._all_create_or_get_groups('<STR_LIT>')[<NUM_LIT:0>]<EOL><DEDENT>return self._overview_group_<EOL>


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

Makes filters

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


def _set_config(name, value, comment):<EOL><INDENT>if not trajectory.f_contains('<STR_LIT>'+name, shortcuts=False):<EOL><INDENT>trajectory.f_add_config(Parameter, name, value, comment=comment)<EOL><DEDENT><DEDENT>for attr_name in HDF5StorageService.NAME_TABLE_MAPPING:<EOL><INDENT>table_name = HDF5StorageService.NAME_TABLE_MAPPING[attr_name]<EOL>value = getattr(self, attr_name)<EOL>_set_config('<STR_LIT>' + table_name,<EOL>value,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>_set_config('<STR_LIT>',<EOL>self._purge_duplicate_comments,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._results_per_run,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>_set_config('<STR_LIT>',<EOL>self._derived_parameters_per_run,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._complevel,<EOL>comment='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._complib,<EOL>comment='<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._encoding,<EOL>comment='<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._fletcher32,<EOL>comment='<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._shuffle,<EOL>comment='<STR_LIT>')<EOL>_set_config('<STR_LIT>', self._pandas_format,<EOL>comment='''<STR_LIT>'''<EOL>'''<STR_LIT>''')<EOL>if trajectory.f_contains('<STR_LIT>', shortcuts=False):<EOL><INDENT>if trajectory.config.hdf5.v_comment == '<STR_LIT>':<EOL><INDENT>trajectory.config.hdf5.v_comment = '<STR_LIT>'<EOL><DEDENT><DEDENT>trajectory.v_storage_service = self<EOL>

Sets a config value to the Trajectory or changes it if the trajectory was loaded
        a the settings no longer match


opened = True<EOL>try:<EOL><INDENT>opened = self._srvc_opening_routine('<STR_LIT:r>', kwargs=kwargs)<EOL>if msg == pypetconstants.TRAJECTORY:<EOL><INDENT>self._trj_load_trajectory(stuff_to_load, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.LEAF:<EOL><INDENT>self._prm_load_parameter_or_result(stuff_to_load, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.GROUP:<EOL><INDENT>self._grp_load_group(stuff_to_load, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.TREE:<EOL><INDENT>self._tree_load_sub_branch(stuff_to_load, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.LIST:<EOL><INDENT>self._srvc_load_several_items(stuff_to_load, *args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>raise pex.NoSuchServiceError('<STR_LIT>' % msg)<EOL><DEDENT><DEDENT>except pt.NoSuchNodeError as exc:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(stuff_to_load))<EOL>raise pex.DataNotInStorageError(repr(exc))<EOL><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(stuff_to_load))<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>self._srvc_closing_routine(opened)<EOL><DEDENT>

Loads a particular item from disk.

        The storage service always accepts these parameters:

        :param trajectory_name: Name of current trajectory and name of top node in hdf5 file.

        :param trajectory_index:

            If no `trajectory_name` is provided, you can specify an integer index.
            The trajectory at the index position in the hdf5 file is considered to loaded.
            Negative indices are also possible for reverse indexing.

        :param filename: Name of the hdf5 file

        The following messages (first argument msg) are understood and the following arguments
        can be provided in combination with the message:

            * :const:`pypet.pypetconstants.TRAJECTORY` ('TRAJECTORY')

                Loads a trajectory.

                :param stuff_to_load: The trajectory

                :param as_new: Whether to load trajectory as new

                :param load_parameters: How to load parameters and config

                :param load_derived_parameters: How to load derived parameters

                :param load_results: How to load results

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

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

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

                    Nothing is loaded

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

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

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

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

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

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

            * :const:`pypet.pypetconstants.LEAF` ('LEAF')

                Loads a parameter or result.

                :param stuff_to_load: The item to be loaded

                :param load_data: How to load data

                :param load_only:

                    If you load a result, you can partially load it and ignore the
                    rest of the data. 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']`.

                    Issues a warning if items cannot be found.

                :param load_except:

                    If you load a result you can partially load in and specify items
                    that should NOT be loaded here. You cannot use `load_except` and
                    `load_only` at the same time.

            * :const:`pypet.pyetconstants.GROUP`

                Loads a group a node (comment and annotations)

                :param recursive:

                    Recursively loads everything below

                :param load_data:

                    How to load stuff if ``recursive=True``
                    accepted values as above for loading the trajectory

                :param max_depth:

                    Maximum depth in case of recursion. `None` for no limit.

            * :const:`pypet.pypetconstants.TREE` ('TREE')

                Loads a whole subtree

                :param stuff_to_load: The parent node (!) not the one where loading starts!

                :param child_name: Name of child node that should be loaded

                :param recursive: Whether to load recursively the subtree below child

                :param load_data:

                    How to load stuff, accepted values as above for loading the trajectory

                :param max_depth:

                    Maximum depth in case of recursion. `None` for no limit.

                :param trajectory: The trajectory object

            * :const:`pypet.pypetconstants.LIST` ('LIST')

                Analogous to :ref:`storing lists <store-lists>`

        :raises:

            NoSuchServiceError if message or data is not understood

            DataNotInStorageError if data to be loaded cannot be found on disk


opened = True<EOL>try:<EOL><INDENT>opened = self._srvc_opening_routine('<STR_LIT:a>', msg, kwargs)<EOL>if msg == pypetconstants.MERGE:<EOL><INDENT>self._trj_merge_trajectories(*args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.BACKUP:<EOL><INDENT>self._trj_backup_trajectory(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.PREPARE_MERGE:<EOL><INDENT>self._trj_prepare_merge(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.TRAJECTORY:<EOL><INDENT>self._trj_store_trajectory(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.SINGLE_RUN:<EOL><INDENT>self._srn_store_single_run(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg in pypetconstants.LEAF:<EOL><INDENT>self._prm_store_parameter_or_result(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.DELETE:<EOL><INDENT>self._all_delete_parameter_or_result_or_group(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.GROUP:<EOL><INDENT>self._grp_store_group(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.TREE:<EOL><INDENT>self._tree_store_sub_branch(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.DELETE_LINK:<EOL><INDENT>self._lnk_delete_link(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.LIST:<EOL><INDENT>self._srvc_store_several_items(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.ACCESS_DATA:<EOL><INDENT>return self._hdf5_interact_with_data(stuff_to_store, *args, **kwargs)<EOL><DEDENT>elif msg == pypetconstants.OPEN_FILE:<EOL><INDENT>opened = False  <EOL>self._keep_open = True<EOL>self._node_processing_timer.active = False <EOL><DEDENT>elif msg == pypetconstants.CLOSE_FILE:<EOL><INDENT>opened = True  <EOL>self._keep_open = False<EOL><DEDENT>elif msg == pypetconstants.FLUSH:<EOL><INDENT>self._hdf5file.flush()<EOL><DEDENT>else:<EOL><INDENT>raise pex.NoSuchServiceError('<STR_LIT>' % msg)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(stuff_to_store))<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>self._srvc_closing_routine(opened)<EOL><DEDENT>

Stores a particular item to disk.

        The storage service always accepts these parameters:

        :param trajectory_name: Name or current trajectory and name of top node in hdf5 file

        :param filename: Name of the hdf5 file

        :param file_title: If file needs to be created, assigns a title to the file.

        The following messages (first argument msg) are understood and the following arguments
        can be provided in combination with the message:

            * :const:`pypet.pypetconstants.PREPARE_MERGE` ('PREPARE_MERGE'):

                Called to prepare a trajectory for merging, see also 'MERGE' below.

                Will also be called if merging cannot happen within the same hdf5 file.
                Stores already enlarged parameters and updates meta information.

                :param stuff_to_store: Trajectory that is about to be extended by another one

                :param changed_parameters:

                    List containing all parameters that were enlarged due to merging

                :param old_length:

                    Old length of trajectory before merge

            * :const:`pypet.pypetconstants.MERGE` ('MERGE')

                Note that before merging within HDF5 file, the storage service will be called
                with msg='PREPARE_MERGE' before, see above.

                Raises a ValueError if the two trajectories are not stored within the very
                same hdf5 file. Then the current trajectory needs to perform the merge slowly
                item by item.

                Merges two trajectories, parameters are:

                :param stuff_to_store: The trajectory data is merged into

                :param other_trajectory_name: Name of the other trajectory

                :param rename_dict:

                    Dictionary containing the old result and derived parameter names in the
                    other trajectory and their new names in the current trajectory.

                :param move_nodes:

                    Whether to move the nodes from the other to the current trajectory

                :param delete_trajectory:

                    Whether to delete the other trajectory after merging.

            * :const:`pypet.pypetconstants.BACKUP` ('BACKUP')

                :param stuff_to_store: Trajectory to be backed up

                :param backup_filename:

                    Name of file where to store the backup. If None the backup file will be in
                    the same folder as your hdf5 file and named 'backup_XXXXX.hdf5'
                    where 'XXXXX' is the name of your current trajectory.

            * :const:`pypet.pypetconstants.TRAJECTORY` ('TRAJECTORY')

                Stores the whole trajectory

                :param stuff_to_store: The trajectory to be stored

                :param only_init:

                    If you just want to initialise the store. If yes, only meta information about
                    the trajectory is stored and none of the nodes/leaves within the trajectory.

                :param store_data:

                    How to store data, the following settings are understood:

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

                        Nothing is stored

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

                        Data of not already stored nodes is stored

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

                        Data of all nodes is stored. However, existing data on disk is left
                        untouched.

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

                        Data of all nodes is stored and data on disk is overwritten.
                        May lead to fragmentation of the HDF5 file. The user is adviced
                        to recompress the file manually later on.

            * :const:`pypet.pypetconstants.SINGLE_RUN` ('SINGLE_RUN')

                :param stuff_to_store: The trajectory

                :param store_data: How to store data see above

                :param store_final: If final meta info should be stored

            * :const:`pypet.pypetconstants.LEAF`

                Stores a parameter or result

                Note that everything that is supported by the storage service and that is
                stored to disk will be perfectly recovered.
                For instance, you store a tuple of numpy 32 bit integers, you will get a tuple
                of numpy 32 bit integers after loading independent of the platform!

                :param stuff_to_sore: Result or parameter to store

                    In order to determine what to store, the function '_store' of the parameter or
                    result is called. This function returns a dictionary with name keys and data to
                    store as values. In order to determine how to store the data, the storage flags
                    are considered, see below.

                    The function '_store' has to return a dictionary containing values only from
                    the following objects:

                        * python natives (int, long, str, bool, float, complex),

                        *
                            numpy natives, arrays and matrices of type np.int8-64, np.uint8-64,
                            np.float32-64, np.complex, np.str

                        *

                            python lists and tuples of the previous types
                            (python natives + numpy natives and arrays)
                            Lists and tuples are not allowed to be nested and must be
                            homogeneous, i.e. only contain data of one particular type.
                            Only integers, or only floats, etc.

                        *

                            python dictionaries of the previous types (not nested!), data can be
                            heterogeneous, keys must be strings. For example, one key-value-pair
                            of string and int and one key-value pair of string and float, and so
                            on.

                        * pandas DataFrames_

                        * :class:`~pypet.parameter.ObjectTable`

                    .. _DataFrames: http://pandas.pydata.org/pandas-docs/dev/dsintro.html#dataframe

                    The keys from the '_store' dictionaries determine how the data will be named
                    in the hdf5 file.

                :param store_data:

                    How to store the data, see above for a descitpion.

                :param store_flags: Flags describing how to store data.

                        :const:`~pypet.HDF5StorageService.ARRAY` ('ARRAY')

                            Store stuff as array

                        :const:`~pypet.HDF5StorageService.CARRAY` ('CARRAY')

                            Store stuff as carray

                        :const:`~pypet.HDF5StorageService.TABLE` ('TABLE')

                            Store stuff as pytable

                        :const:`~pypet.HDF5StorageService.DICT` ('DICT')

                            Store stuff as pytable but reconstructs it later as dictionary
                            on loading

                        :const:`~pypet.HDF%StorageService.FRAME` ('FRAME')

                            Store stuff as pandas data frame

                    Storage flags can also be provided by the parameters and results themselves
                    if they implement a function '_store_flags' that returns a dictionary
                    with the names of the data to store as keys and the flags as values.

                    If no storage flags are provided, they are automatically inferred from the
                    data. See :const:`pypet.HDF5StorageService.TYPE_FLAG_MAPPING` for the mapping
                    from type to flag.

                :param overwrite:

                    Can be used if parts of a leaf should be replaced. Either a list of
                    HDF5 names or `True` if this should account for all.

            * :const:`pypet.pypetconstants.DELETE` ('DELETE')

                Removes an item from disk. Empty group nodes, results and non-explored
                parameters can be removed.

                :param stuff_to_store: The item to be removed.

                :param delete_only:

                    Potential list of parts of a leaf node that should be deleted.

                :param remove_from_item:

                    If `delete_only` is used, whether deleted nodes should also be erased
                    from the leaf nodes themseleves.

                :param recursive:

                    If you want to delete a group node you can recursively delete all its
                    children.

            * :const:`pypet.pypetconstants.GROUP` ('GROUP')

                :param stuff_to_store: The group to store

                :param store_data: How to store data

                :param recursive: To recursively load everything below.

                :param max_depth:

                    Maximum depth in case of recursion. `None` for no limit.

            * :const:`pypet.pypetconstants.TREE`

                Stores a single node or a full subtree

                :param stuff_to_store: Node to store

                :param store_data: How to store data

                :param recursive: Whether to store recursively the whole sub-tree

                :param max_depth:

                    Maximum depth in case of recursion. `None` for no limit.

            * :const:`pypet.pypetconstants.DELETE_LINK`

                Deletes a link from hard drive

                :param name: The full colon separated name of the link

            * :const:`pypet.pypetconstants.LIST`

                .. _store-lists:

                Stores several items at once

                :param stuff_to_store:

                    Iterable whose items are to be stored. Iterable must contain tuples,
                    for example `[(msg1,item1,arg1,kwargs1),(msg2,item2,arg2,kwargs2),...]`

            * :const:`pypet.pypetconstants.ACCESS_DATA`

                Requests and manipulates data within the storage.
                Storage must be open.

                :param stuff_to_store:

                    A colon separated name to the data path

                :param item_name:

                    The name of the data item to interact with

                :param request:

                    A functional request in form of a string

                :param args:

                    Positional arguments passed to the reques

                :param kwargs:

                    Keyword arguments passed to the request

            * :const:`pypet.pypetconstants.OPEN_FILE`

                Opens the HDF5 file and keeps it open

                :param stuff_to_store: ``None``

            * :const:`pypet.pypetconstants.CLOSE_FILE`

                Closes an HDF5 file that was kept open, must be open before.

                :param stuff_to_store: ``None``

            * :const:`pypet.pypetconstants.FLUSH`

                Flushes an open file, must be open before.

                :param stuff_to_store: ``None``

        :raises: NoSuchServiceError if message or data is not understood


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

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

Loads several items from an iterable

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


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

Reads out the properties for storing new data into the hdf5file

        :param traj:

            The trajectory


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

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

Stores several items from an iterable

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


def _srvc_opening_routine(self, mode, msg=None, kwargs=()):

self._mode = mode<EOL>self._srvc_extract_file_information(kwargs)<EOL>if not self.is_open:<EOL><INDENT>if '<STR_LIT:a>' in mode:<EOL><INDENT>(path, filename) = os.path.split(self._filename)<EOL>racedirs(os.path.abspath(path))<EOL>self._hdf5store = HDFStore(self._filename, mode=self._mode, complib=self._complib,<EOL>complevel=self._complevel, fletcher32=self._fletcher32)<EOL>self._hdf5file = self._hdf5store._handle<EOL>self._hdf5file.title = self._file_title<EOL>if self._trajectory_name is not None:<EOL><INDENT>if not '<STR_LIT:/>' + self._trajectory_name in self._hdf5file:<EOL><INDENT>if not msg == pypetconstants.TRAJECTORY:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._trajectory_group = self._hdf5file.get_node('<STR_LIT:/>' +<EOL>self._trajectory_name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self._logger.debug('<STR_LIT>' %<EOL>(self._filename, self._trajectory_name))<EOL><DEDENT>elif mode == '<STR_LIT:r>':<EOL><INDENT>if self._trajectory_name is not None and self._trajectory_index is not None:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not os.path.isfile(self._filename):<EOL><INDENT>raise ValueError('<STR_LIT>' + self._filename + '<STR_LIT>')<EOL><DEDENT>self._hdf5store = HDFStore(self._filename, mode=self._mode, complib=self._complib,<EOL>complevel=self._complevel, fletcher32=self._fletcher32)<EOL>self._hdf5file = self._hdf5store._handle<EOL>if self._trajectory_index is not None:<EOL><INDENT>nodelist = self._hdf5file.list_nodes(where='<STR_LIT:/>')<EOL>if (self._trajectory_index >= len(nodelist) or<EOL>self._trajectory_index < -len(nodelist)):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (self._trajectory_index, len(nodelist), self._filename))<EOL><DEDENT>self._trajectory_group = nodelist[self._trajectory_index]<EOL>self._trajectory_name = self._trajectory_group._v_name<EOL><DEDENT>elif self._trajectory_name is not None:<EOL><INDENT>if not '<STR_LIT:/>' + self._trajectory_name in self._hdf5file:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>% (self._filename, self._trajectory_name))<EOL><DEDENT>self._trajectory_group = self._hdf5file.get_node('<STR_LIT:/>' + self._trajectory_name)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._logger.debug('<STR_LIT>' %<EOL>(self._filename, self._trajectory_name))<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>self._node_processing_timer = NodeProcessingTimer(display_time=self._display_time,<EOL>logger_name=self._logger.name)<EOL>self._overview_group_ = None<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>

Opens an hdf5 file for reading or writing

        The file is only opened if it has not been opened before (i.e. `self._hdf5file is None`).

        :param mode:

            'a' for appending

            'r' for reading

                Unfortunately, pandas currently does not work with read-only mode.
                Thus, if mode is chosen to be 'r', the file will still be opened in
                append mode.

        :param msg:

            Message provided to `load` or `store`. Only considered to check if a trajectory
            was stored before.

        :param kwargs:

            Arguments to extract file information from

        :return:

            `True` if file is opened

            `False` if the file was already open before calling this function


if (not self._keep_open and<EOL>closing and<EOL>self.is_open):<EOL><INDENT>f_fd = self._hdf5file.fileno()<EOL>self._hdf5file.flush()<EOL>try:<EOL><INDENT>os.fsync(f_fd)<EOL>try:<EOL><INDENT>self._hdf5store.flush(fsync=True)<EOL><DEDENT>except TypeError:<EOL><INDENT>f_fd = self._hdf5store._handle.fileno()<EOL>self._hdf5store.flush()<EOL>os.fsync(f_fd)<EOL><DEDENT><DEDENT>except OSError as exc:<EOL><INDENT>errmsg = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % repr(exc))<EOL>self._logger.debug(errmsg)<EOL><DEDENT>self._hdf5store.close()<EOL>if self._hdf5file.isopen:<EOL><INDENT>self._logger.error('<STR_LIT>')<EOL><DEDENT>self._hdf5file = None<EOL>self._hdf5store = None<EOL>self._trajectory_group = None<EOL>self._trajectory_name = None<EOL>self._trajectory_index = None<EOL>self._overview_group_ = None<EOL>self._logger.debug('<STR_LIT>')<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>

Routine to close an hdf5 file

        The file is closed only when `closing=True`. `closing=True` means that
        the file was opened in the current highest recursion level. This prevents re-opening
        and closing of the file if `store` or `load` are called recursively.


if '<STR_LIT:filename>' in kwargs:<EOL><INDENT>self._filename = kwargs.pop('<STR_LIT:filename>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self._file_title = kwargs.pop('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self._trajectory_name = kwargs.pop('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>self._trajectory_index = kwargs.pop('<STR_LIT>')<EOL><DEDENT>

Extracts file information from kwargs.

        Note that `kwargs` is not passed as `**kwargs` in order to also
        `pop` the elements on the level of the function calling `_srvc_extract_file_information`.


def _trj_backup_trajectory(self, traj, backup_filename=None):

self._logger.info('<STR_LIT>' % traj.v_name)<EOL>mypath, _ = os.path.split(self._filename)<EOL>if backup_filename is None:<EOL><INDENT>backup_filename = os.path.join('<STR_LIT:%s>' % mypath, '<STR_LIT>' % traj.v_name)<EOL><DEDENT>backup_hdf5file = pt.open_file(filename=backup_filename,<EOL>mode='<STR_LIT:a>', title=backup_filename)<EOL>if '<STR_LIT:/>' + self._trajectory_name in backup_hdf5file:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (traj.v_name, backup_filename))<EOL><DEDENT>backup_root = backup_hdf5file.root<EOL>self._trajectory_group._f_copy(newparent=backup_root, recursive=True)<EOL>backup_hdf5file.flush()<EOL>backup_hdf5file.close()<EOL>self._logger.info('<STR_LIT>' % traj.v_name)<EOL>

Backs up a trajectory.

        :param traj: Trajectory that should be backed up

        :param backup_filename:

            Path and filename of backup file. If None is specified the storage service
            defaults to `path_to_trajectory_hdf5_file/backup_trajectory_name.hdf`.


result_dict = {}<EOL>for colname in colnames:<EOL><INDENT>result_dict[colname] = row[colname]<EOL><DEDENT>return result_dict<EOL>

Reads out a row and returns a dictionary containing the row content.

        :param colnames: List of column names
        :param row:  A pytables table row
        :return: A dictionary with colnames as keys and content as values


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

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

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

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


def _trj_prepare_merge(self, traj, changed_parameters, old_length):

if not traj._stored:<EOL><INDENT>traj.f_store()<EOL><DEDENT>infotable = getattr(self._overview_group, '<STR_LIT:info>')<EOL>insert_dict = self._all_extract_insert_dict(traj, infotable.colnames)<EOL>self._all_add_or_modify_row(traj.v_name, insert_dict, infotable, index=<NUM_LIT:0>,<EOL>flags=(HDF5StorageService.MODIFY_ROW,))<EOL>for param_name in changed_parameters:<EOL><INDENT>param = traj.f_get(param_name)<EOL>try:<EOL><INDENT>self._all_delete_parameter_or_result_or_group(param)<EOL><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>pass  <EOL><DEDENT><DEDENT>run_table = getattr(self._overview_group, '<STR_LIT>')<EOL>actual_rows = run_table.nrows<EOL>self._trj_fill_run_table(traj, actual_rows, len(traj))<EOL>for idx in range(old_length, len(traj)):<EOL><INDENT>run_name = traj.f_idx_to_run(idx)<EOL>run_info = traj.f_get_run_information(run_name)<EOL>run_info['<STR_LIT:name>'] = run_name<EOL>traj._set_explored_parameters_to_idx(idx)<EOL>run_summary = self._srn_summarize_explored_parameters(list(<EOL>traj._explored_parameters.values()))<EOL>run_info['<STR_LIT>'] = run_summary<EOL>self._all_add_or_modify_row(run_name, run_info, run_table, index=idx,<EOL>flags=(HDF5StorageService.MODIFY_ROW,))<EOL><DEDENT>traj.f_restore_default()<EOL>

Prepares a trajectory for merging.

        This function will already store extended parameters.

        :param traj: Target of merge
        :param changed_parameters: List of extended parameters (i.e. their names).


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

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

Loads a single trajectory from a given file.

        :param traj: The trajectory

        :param as_new: Whether to load trajectory as new

        :param load_parameters: How to load parameters and config

        :param load_derived_parameters: How to load derived parameters

        :param load_results: How to load results

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

        :param recursive: If data should be loaded recursively

        :param max_depth: Maximum depth of loading

        :param with_run_information:

            If run information should be loaded

        :param with_meta_data:

            If meta data infor should be loaded

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

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

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

            Nothing is loaded

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

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

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

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

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

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

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


def _trj_load_meta_data(self, traj, load_data, as_new, with_run_information, force):

metatable = self._overview_group.info<EOL>metarow = metatable[<NUM_LIT:0>]<EOL>try:<EOL><INDENT>version = metarow['<STR_LIT:version>'].decode('<STR_LIT:utf-8>')<EOL><DEDENT>except (IndexError, ValueError) as ke:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(ke))<EOL>version = '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>python = metarow['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL><DEDENT>except (IndexError, ValueError) as ke:<EOL><INDENT>self._logger.error('<STR_LIT>' % str(ke))<EOL>python = '<STR_LIT>'<EOL><DEDENT>self._trj_check_version(version, python, force)<EOL>self._grp_load_group(traj, load_data=load_data,<EOL>with_links=False, recursive=False, _traj=traj,<EOL>_as_new=as_new, _hdf5_group=self._trajectory_group)<EOL>if as_new:<EOL><INDENT>length = int(metarow['<STR_LIT>'])<EOL>for irun in range(length):<EOL><INDENT>traj._add_run_info(irun)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>traj._comment =  metarow['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL>traj._timestamp = float(metarow['<STR_LIT>'])<EOL>traj._trajectory_timestamp = traj._timestamp<EOL>traj._time = metarow['<STR_LIT:time>'].decode('<STR_LIT:utf-8>')<EOL>traj._trajectory_time = traj._time<EOL>traj._name = metarow['<STR_LIT:name>'].decode('<STR_LIT:utf-8>')<EOL>traj._trajectory_name = traj._name<EOL>traj._version = version<EOL>traj._python = python<EOL>single_run_table = self._overview_group.runs<EOL>if with_run_information:<EOL><INDENT>for row in single_run_table.iterrows():<EOL><INDENT>name = row['<STR_LIT:name>'].decode('<STR_LIT:utf-8>')<EOL>idx = int(row['<STR_LIT>'])<EOL>timestamp = float(row['<STR_LIT>'])<EOL>time_ = row['<STR_LIT:time>'].decode('<STR_LIT:utf-8>')<EOL>completed = int(row['<STR_LIT>'])<EOL>summary = row['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL>hexsha = row['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL>try:<EOL><INDENT>runtime = row['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL>finish_timestamp = float(row['<STR_LIT>'])<EOL><DEDENT>except (IndexError, ValueError) as ke:<EOL><INDENT>runtime = '<STR_LIT>'<EOL>finish_timestamp = <NUM_LIT:0.0><EOL>self._logger.debug('<STR_LIT>' + repr(ke))<EOL><DEDENT>info_dict = {'<STR_LIT>': idx,<EOL>'<STR_LIT>': timestamp,<EOL>'<STR_LIT>': finish_timestamp,<EOL>'<STR_LIT>': runtime,<EOL>'<STR_LIT:time>': time_,<EOL>'<STR_LIT>': completed,<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': summary,<EOL>'<STR_LIT>': hexsha}<EOL>traj._add_run_info(**info_dict)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>traj._length = single_run_table.nrows<EOL><DEDENT><DEDENT>self._trj_load_exploration(traj)<EOL>self._srvc_load_hdf5_settings()<EOL>

Loads meta information about the trajectory

        Checks if the version number does not differ from current pypet version
        Loads, comment, timestamp, name, version from disk in case trajectory is not loaded
        as new. Updates the run information as well.


def _tree_load_sub_branch(self, traj_node, branch_name,<EOL>load_data=pypetconstants.LOAD_DATA,<EOL>with_links=True, recursive=False,<EOL>max_depth=None, _trajectory=None,<EOL>_as_new=False, _hdf5_group=None):

if load_data == pypetconstants.LOAD_NOTHING:<EOL><INDENT>return<EOL><DEDENT>if max_depth is None:<EOL><INDENT>max_depth = float('<STR_LIT>')<EOL><DEDENT>if _trajectory is None:<EOL><INDENT>_trajectory = traj_node.v_root<EOL><DEDENT>if _hdf5_group is None:<EOL><INDENT>hdf5_group_name = traj_node.v_full_name.replace('<STR_LIT:.>', '<STR_LIT:/>')<EOL>if hdf5_group_name == '<STR_LIT>':<EOL><INDENT>_hdf5_group = self._trajectory_group<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>_hdf5_group = self._hdf5file.get_node(where=self._trajectory_group,<EOL>name=hdf5_group_name)<EOL><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>% (traj_node.v_full_name, hdf5_group_name))<EOL>raise<EOL><DEDENT><DEDENT><DEDENT>split_names = branch_name.split('<STR_LIT:.>')<EOL>final_group_name = split_names.pop()<EOL>current_depth = <NUM_LIT:1><EOL>for name in split_names:<EOL><INDENT>if current_depth > max_depth:<EOL><INDENT>return<EOL><DEDENT>_hdf5_group = getattr(_hdf5_group, name)<EOL>self._tree_load_nodes_dfs(traj_node, load_data=load_data, with_links=with_links,<EOL>recursive=False, max_depth=max_depth, current_depth=current_depth,<EOL>trajectory=_trajectory, as_new=_as_new,<EOL>hdf5_group=_hdf5_group)<EOL>current_depth += <NUM_LIT:1><EOL>traj_node = traj_node._children[name]<EOL><DEDENT>if current_depth <= max_depth:<EOL><INDENT>_hdf5_group = getattr(_hdf5_group, final_group_name)<EOL>self._tree_load_nodes_dfs(traj_node, load_data=load_data, with_links=with_links,<EOL>recursive=recursive, max_depth=max_depth,<EOL>current_depth=current_depth, trajectory=_trajectory,<EOL>as_new=_as_new, hdf5_group=_hdf5_group)<EOL><DEDENT>

Loads data starting from a node along a branch and starts recursively loading
        all data at end of branch.

        :param traj_node: The node from where loading starts

        :param branch_name:

            A branch along which loading progresses. Colon Notation is used:
            'group1.group2.group3' loads 'group1', then 'group2', then 'group3' and then finally
            recursively all children and children's children below 'group3'

        :param load_data:

            How to load the data

        :param with_links:

            If links should be loaded

        :param recursive:

            If loading recursively

        :param max_depth:

            The maximum depth to load the tree

        :param _trajectory:

            The trajectory

        :param _as_new:

            If trajectory is loaded as new

        :param _hdf5_group:

            HDF5 node in the file corresponding to `traj_node`.


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

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

Checks for version mismatch

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


def _trj_fill_run_table(self, traj, start, stop):

def _make_row(info_dict):<EOL><INDENT>row = (info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT:name>'],<EOL>info_dict['<STR_LIT:time>'],<EOL>info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT>'],<EOL>info_dict['<STR_LIT>'])<EOL>return row<EOL><DEDENT>runtable = getattr(self._overview_group, '<STR_LIT>')<EOL>rows = []<EOL>updated_run_information = traj._updated_run_information<EOL>for idx in range(start, stop):<EOL><INDENT>info_dict = traj._run_information[traj._single_run_ids[idx]]<EOL>rows.append(_make_row(info_dict))<EOL>updated_run_information.discard(idx)<EOL><DEDENT>if rows:<EOL><INDENT>runtable.append(rows)<EOL>runtable.flush()<EOL><DEDENT>rows = []<EOL>indices = []<EOL>for idx in updated_run_information:<EOL><INDENT>info_dict = traj.f_get_run_information(idx, copy=False)<EOL>rows.append(_make_row(info_dict))<EOL>indices.append(idx)<EOL><DEDENT>if rows:<EOL><INDENT>runtable.modify_coordinates(indices, rows)<EOL><DEDENT>traj._updated_run_information = set()<EOL>

Fills the `run` overview table with information.

        Will also update new information.


<EOL>descriptiondict = {'<STR_LIT:name>': pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_LOCATION_LENGTH,<EOL>pos=<NUM_LIT:0>),<EOL>'<STR_LIT:time>': pt.StringCol(len(traj.v_time), pos=<NUM_LIT:1>),<EOL>'<STR_LIT>': pt.FloatCol(pos=<NUM_LIT:3>),<EOL>'<STR_LIT>': pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_COMMENT_LENGTH,<EOL>pos=<NUM_LIT:4>),<EOL>'<STR_LIT>': pt.IntCol(pos=<NUM_LIT:2>),<EOL>'<STR_LIT:version>': pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH,<EOL>pos=<NUM_LIT:5>),<EOL>'<STR_LIT>': pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH,<EOL>pos=<NUM_LIT:5>)}<EOL>infotable = self._all_get_or_create_table(where=self._overview_group, tablename='<STR_LIT:info>',<EOL>description=descriptiondict,<EOL>expectedrows=len(traj))<EOL>insert_dict = self._all_extract_insert_dict(traj, infotable.colnames)<EOL>self._all_add_or_modify_row(traj.v_name, insert_dict, infotable, index=<NUM_LIT:0>,<EOL>flags=(HDF5StorageService.ADD_ROW,<EOL>HDF5StorageService.MODIFY_ROW))<EOL>rundescription_dict = {'<STR_LIT:name>': pt.StringCol(pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH,<EOL>pos=<NUM_LIT:1>),<EOL>'<STR_LIT:time>': pt.StringCol(len(traj.v_time), pos=<NUM_LIT:2>),<EOL>'<STR_LIT>': pt.FloatCol(pos=<NUM_LIT:3>),<EOL>'<STR_LIT>': pt.IntCol(pos=<NUM_LIT:0>),<EOL>'<STR_LIT>': pt.IntCol(pos=<NUM_LIT:8>),<EOL>'<STR_LIT>': pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_COMMENT_LENGTH,<EOL>pos=<NUM_LIT:6>),<EOL>'<STR_LIT>': pt.StringCol(<NUM_LIT:7>, pos=<NUM_LIT:7>),<EOL>'<STR_LIT>': pt.FloatCol(pos=<NUM_LIT:4>),<EOL>'<STR_LIT>': pt.StringCol(<EOL>pypetconstants.HDF5_STRCOL_MAX_RUNTIME_LENGTH,<EOL>pos=<NUM_LIT:5>)}<EOL>runtable = self._all_get_or_create_table(where=self._overview_group,<EOL>tablename='<STR_LIT>',<EOL>description=rundescription_dict)<EOL>hdf5_description_dict = {'<STR_LIT>': pt.StringCol(<NUM_LIT:7>, pos=<NUM_LIT:0>),<EOL>'<STR_LIT>': pt.IntCol(pos=<NUM_LIT:1>),<EOL>'<STR_LIT>': pt.BoolCol(pos=<NUM_LIT:2>),<EOL>'<STR_LIT>': pt.BoolCol(pos=<NUM_LIT:3>),<EOL>'<STR_LIT>': pt.StringCol(<NUM_LIT:7>, pos=<NUM_LIT:4>),<EOL>'<STR_LIT>': pt.StringCol(<NUM_LIT:11>, pos=<NUM_LIT:5>)}<EOL>pos = <NUM_LIT:7><EOL>for name, table_name in HDF5StorageService.NAME_TABLE_MAPPING.items():<EOL><INDENT>hdf5_description_dict[table_name] = pt.BoolCol(pos=pos)<EOL>pos += <NUM_LIT:1><EOL><DEDENT>hdf5_description_dict.update({'<STR_LIT>': pt.BoolCol(pos=pos + <NUM_LIT:2>),<EOL>'<STR_LIT>': pt.IntCol(pos=pos + <NUM_LIT:3>),<EOL>'<STR_LIT>': pt.IntCol(pos=pos + <NUM_LIT:4>)})<EOL>hdf5table = self._all_get_or_create_table(where=self._overview_group,<EOL>tablename='<STR_LIT>',<EOL>description=hdf5_description_dict)<EOL>insert_dict = {}<EOL>for attr_name in self.ATTR_LIST:<EOL><INDENT>insert_dict[attr_name] = getattr(self, attr_name)<EOL><DEDENT>for attr_name, table_name in self.NAME_TABLE_MAPPING.items():<EOL><INDENT>insert_dict[table_name] = getattr(self, attr_name)<EOL><DEDENT>for attr_name, name in self.PR_ATTR_NAME_MAPPING.items():<EOL><INDENT>insert_dict[name] = getattr(self, attr_name)<EOL><DEDENT>self._all_add_or_modify_row(traj.v_name, insert_dict, hdf5table, index=<NUM_LIT:0>,<EOL>flags=(HDF5StorageService.ADD_ROW,<EOL>HDF5StorageService.MODIFY_ROW))<EOL>actual_rows = runtable.nrows<EOL>self._trj_fill_run_table(traj, actual_rows, len(traj._run_information))<EOL>self._grp_store_group(traj, store_data=pypetconstants.STORE_DATA,<EOL>with_links=False,<EOL>recursive=False,<EOL>_hdf5_group=self._trajectory_group)<EOL>self._trj_store_explorations(traj)<EOL>tostore_tables = []<EOL>for name, table_name in HDF5StorageService.NAME_TABLE_MAPPING.items():<EOL><INDENT>if getattr(self, name):<EOL><INDENT>tostore_tables.append(table_name)<EOL><DEDENT><DEDENT>self._srvc_make_overview_tables(tostore_tables, traj)<EOL>

Stores general information about the trajectory in the hdf5file.

        The `info` table will contain the name of the trajectory, it's timestamp, a comment,
        the length (aka the number of single runs), and the current version number of pypet.

        Also prepares the desired overview tables and fills the `run` table with dummies.


if hasattr(self._overview_group, '<STR_LIT>'):<EOL><INDENT>explorations_table = self._overview_group._f_get_child( '<STR_LIT>')<EOL>for row in explorations_table.iterrows():<EOL><INDENT>param_name = row['<STR_LIT>'].decode('<STR_LIT:utf-8>')<EOL>if param_name not in traj._explored_parameters:<EOL><INDENT>traj._explored_parameters[param_name] = None<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for what in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if hasattr(self._trajectory_group, what):<EOL><INDENT>parameters = self._trajectory_group._f_get_child(what)<EOL>for group in parameters._f_walk_groups():<EOL><INDENT>if self._all_get_from_attrs(group, HDF5StorageService.LENGTH):<EOL><INDENT>group_location = group._v_pathname<EOL>full_name = '<STR_LIT:.>'.join(group_location.split('<STR_LIT:/>')[<NUM_LIT:2>:])<EOL>traj._explored_parameters[full_name] = None<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>

Recalls names of all explored parameters


nexplored = len(traj._explored_parameters)<EOL>if nexplored > <NUM_LIT:0>:<EOL><INDENT>if hasattr(self._overview_group, '<STR_LIT>'):<EOL><INDENT>explorations_table = self._overview_group._f_get_child('<STR_LIT>')<EOL>if len(explorations_table) != nexplored:<EOL><INDENT>self._hdf5file.remove_node(where=self._overview_group,<EOL>name='<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if not hasattr(self._overview_group, '<STR_LIT>'):<EOL><INDENT>explored_list = list(traj._explored_parameters.keys())<EOL>if explored_list:<EOL><INDENT>string_col = self._all_get_table_col('<STR_LIT>',<EOL>explored_list,<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>string_col = pt.StringCol(<NUM_LIT:1>)<EOL><DEDENT>description = {'<STR_LIT>': string_col}<EOL>explorations_table = self._hdf5file.create_table(where=self._overview_group,<EOL>name='<STR_LIT>',<EOL>description=description)<EOL>rows = [(x.encode('<STR_LIT:utf-8>'),) for x in explored_list]<EOL>if rows:<EOL><INDENT>explorations_table.append(rows)<EOL>explorations_table.flush()<EOL><DEDENT><DEDENT>

Stores a all explored parameter names for internal recall


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

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

Creates the overview tables in overview group


def _trj_store_trajectory(self, traj, only_init=False, store_data=pypetconstants.STORE_DATA,<EOL>max_depth=None):

if not only_init:<EOL><INDENT>self._logger.info('<STR_LIT>' % self._trajectory_name)<EOL><DEDENT>else:<EOL><INDENT>self._logger.info('<STR_LIT>' %<EOL>self._trajectory_name)<EOL>store_data = pypetconstants.STORE_NOTHING<EOL><DEDENT>if not traj._stored and self._trajectory_group is not None:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(traj.v_name, self._filename))<EOL><DEDENT>self._srvc_check_hdf_properties(traj)<EOL>if self._trajectory_group is None:<EOL><INDENT>self._trajectory_group = self._hdf5file.create_group(where='<STR_LIT:/>',<EOL>name=self._trajectory_name,<EOL>title=self._trajectory_name,<EOL>filters=self._all_get_filters())<EOL><DEDENT>self._trj_store_meta_data(traj)<EOL>if store_data in (pypetconstants.STORE_DATA_SKIPPING,<EOL>pypetconstants.STORE_DATA,<EOL>pypetconstants.OVERWRITE_DATA):<EOL><INDENT>counter = <NUM_LIT:0><EOL>maximum_display_other = <NUM_LIT:10><EOL>name_set = set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>for child_name in traj._children:<EOL><INDENT>if child_name in name_set:<EOL><INDENT>self._logger.info('<STR_LIT>' % child_name)<EOL><DEDENT>else:<EOL><INDENT>if counter < maximum_display_other:<EOL><INDENT>self._logger.info('<STR_LIT>' % child_name)<EOL><DEDENT>elif counter == maximum_display_other:<EOL><INDENT>self._logger.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>counter += <NUM_LIT:1><EOL><DEDENT>self._tree_store_sub_branch(traj, child_name, store_data=store_data,<EOL>with_links=True,<EOL>recursive=True, max_depth=max_depth,<EOL>hdf5_group=self._trajectory_group)<EOL><DEDENT>self._logger.info('<STR_LIT>' % self._trajectory_name)<EOL><DEDENT>else:<EOL><INDENT>self._logger.info('<STR_LIT>' %<EOL>self._trajectory_name)<EOL><DEDENT>traj._stored = True<EOL>

Stores a trajectory to an hdf5 file

        Stores all groups, parameters and results


if store_data == pypetconstants.STORE_NOTHING:<EOL><INDENT>return<EOL><DEDENT>if max_depth is None:<EOL><INDENT>max_depth = float('<STR_LIT>')<EOL><DEDENT>if hdf5_group is None:<EOL><INDENT>location = traj_node.v_full_name<EOL>hdf5_location = location.replace('<STR_LIT:.>', '<STR_LIT:/>')<EOL>try:<EOL><INDENT>if location == '<STR_LIT>':<EOL><INDENT>hdf5_group = self._trajectory_group<EOL><DEDENT>else:<EOL><INDENT>hdf5_group = self._hdf5file.get_node( where=self._trajectory_group,<EOL>name=hdf5_location)<EOL><DEDENT><DEDENT>except pt.NoSuchNodeError:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(traj_node.v_name, hdf5_location))<EOL>if traj_node.v_is_leaf:<EOL><INDENT>self._logger.error('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (traj_node.v_name, hdf5_location))<EOL>raise<EOL><DEDENT>else:<EOL><INDENT>self._logger.debug('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self._tree_store_sub_branch(traj_node._nn_interface._root_instance,<EOL>traj_node.v_full_name + '<STR_LIT:.>' + branch_name,<EOL>store_data=store_data, with_links=with_links,<EOL>recursive=recursive,<EOL>max_depth=max_depth + traj_node.v_depth,<EOL>hdf5_group=self._trajectory_group)<EOL>return<EOL><DEDENT><DEDENT><DEDENT>current_depth = <NUM_LIT:1><EOL>split_names = branch_name.split('<STR_LIT:.>')<EOL>leaf_name = split_names.pop()<EOL>for name in split_names:<EOL><INDENT>if current_depth > max_depth:<EOL><INDENT>return<EOL><DEDENT>self._tree_store_nodes_dfs(traj_node, name, store_data=store_data, with_links=with_links,<EOL>recursive=False, max_depth=max_depth,<EOL>current_depth=current_depth, parent_hdf5_group=hdf5_group)<EOL>current_depth += <NUM_LIT:1><EOL>traj_node = traj_node._children[name]<EOL>hdf5_group = getattr(hdf5_group, name)<EOL><DEDENT>if current_depth <= max_depth:<EOL><INDENT>self._tree_store_nodes_dfs(traj_node, leaf_name, store_data=store_data,<EOL>with_links=with_links, recursive=recursive,<EOL>max_depth=max_depth, current_depth=current_depth,<EOL>parent_hdf5_group=hdf5_group)<EOL><DEDENT>

Stores data starting from a node along a branch and starts recursively loading
        all data at end of branch.

        :param traj_node: The node where storing starts

        :param branch_name:

            A branch along which storing progresses. Colon Notation is used:
            'group1.group2.group3' loads 'group1', then 'group2', then 'group3', and then finally
            recursively all children and children's children below 'group3'.

        :param store_data: How data should be stored

        :param with_links: If links should be stored

        :param recursive:

            If the rest of the tree should be recursively stored

        :param max_depth:

            Maximum depth to store

        :param hdf5_group:

            HDF5 node in the file corresponding to `traj_node`


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

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

Creates a new pypet leaf instance.

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


def _tree_load_nodes_dfs(self, parent_traj_node, load_data, with_links, recursive,<EOL>max_depth, current_depth, trajectory, as_new, hdf5_group):

if max_depth is None:<EOL><INDENT>max_depth = float('<STR_LIT>')<EOL><DEDENT>loading_list = [(parent_traj_node, current_depth, hdf5_group)]<EOL>while loading_list:<EOL><INDENT>parent_traj_node, current_depth, hdf5_group = loading_list.pop()<EOL>if isinstance(hdf5_group, pt.link.SoftLink):<EOL><INDENT>if with_links:<EOL><INDENT>self._tree_load_link(parent_traj_node, load_data=load_data, traj=trajectory,<EOL>as_new=as_new, hdf5_soft_link=hdf5_group)<EOL><DEDENT>continue<EOL><DEDENT>name = hdf5_group._v_name<EOL>is_leaf = self._all_get_from_attrs(hdf5_group, HDF5StorageService.LEAF)<EOL>in_trajectory = name in parent_traj_node._children<EOL>if is_leaf:<EOL><INDENT>if in_trajectory:<EOL><INDENT>instance = parent_traj_node._children[name]<EOL><DEDENT>else:<EOL><INDENT>instance = self._tree_create_leaf(name, trajectory, hdf5_group)<EOL>parent_traj_node._add_leaf_from_storage(args=(instance,), kwargs={})<EOL><DEDENT>self._prm_load_parameter_or_result(instance, load_data=load_data,<EOL>_hdf5_group=hdf5_group)<EOL>if as_new:<EOL><INDENT>instance._stored = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if in_trajectory:<EOL><INDENT>traj_group = parent_traj_node._children[name]<EOL>if load_data == pypetconstants.OVERWRITE_DATA:<EOL><INDENT>traj_group.v_annotations.f_empty()<EOL>traj_group.v_comment = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if HDF5StorageService.CLASS_NAME in hdf5_group._v_attrs:<EOL><INDENT>class_name = self._all_get_from_attrs(hdf5_group,<EOL>HDF5StorageService.CLASS_NAME)<EOL>class_constructor = trajectory._create_class(class_name)<EOL>instance = trajectory._construct_instance(class_constructor, name)<EOL>args = (instance,)<EOL><DEDENT>else:<EOL><INDENT>args = (name,)<EOL><DEDENT>traj_group = parent_traj_node._add_group_from_storage(args=args, kwargs={})<EOL><DEDENT>self._grp_load_group(traj_group, load_data=load_data, with_links=with_links,<EOL>recursive=False, max_depth=max_depth,<EOL>_traj=trajectory, _as_new=as_new,<EOL>_hdf5_group=hdf5_group)<EOL>if recursive and current_depth < max_depth:<EOL><INDENT>new_depth = current_depth + <NUM_LIT:1><EOL>for children in (hdf5_group._v_groups, hdf5_group._v_links):<EOL><INDENT>for new_hdf5_group_name in children:<EOL><INDENT>new_hdf5_group = children[new_hdf5_group_name]<EOL>loading_list.append((traj_group, new_depth, new_hdf5_group))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>

Loads a node from hdf5 file and if desired recursively everything below

        :param parent_traj_node: The parent node whose child should be loaded
        :param load_data: How to load the data
        :param with_links: If links should be loaded
        :param recursive: Whether loading recursively below hdf5_group
        :param max_depth: Maximum depth
        :param current_depth: Current depth
        :param trajectory: The trajectory object
        :param as_new: If trajectory is loaded as new
        :param hdf5_group: The hdf5 group containing the child to be loaded


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

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

Loads a link

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