pypet/trajectory.py
def f_explore(self, build_dict):
        """Prepares the trajectory to explore the parameter space.


        To explore the parameter space you need to provide a dictionary with the names of the
        parameters to explore as keys and iterables specifying the exploration ranges as values.

        All iterables need to have the same length otherwise a ValueError is raised.
        A ValueError is also raised if the names from the dictionary map to groups or results
        and not parameters.

        If your trajectory is already explored but not stored yet and your parameters are
        not locked you can add new explored parameters to the current ones if their
        iterables match the current length of the trajectory.

        Raises an AttributeError if the names from the dictionary are not found at all in
        the trajectory and NotUniqueNodeError if the keys not unambiguously map
        to single parameters.

        Raises a TypeError if the trajectory has been stored already, please use
        :func:`~pypet.trajectory.Trajectory.f_expand` then instead.

        Example usage:

        >>> traj.f_explore({'groupA.param1' : [1,2,3,4,5], 'groupA.param2':['a','b','c','d','e']})

        Could also be called consecutively:

        >>> traj.f_explore({'groupA.param1' : [1,2,3,4,5]})
        >>> traj.f_explore({'groupA.param2':['a','b','c','d','e']})

        NOTE:

        Since parameters are very conservative regarding the data they accept
        (see :ref:`type_conservation`), you sometimes won't be able to use Numpy arrays
        for exploration as iterables.

        For instance, the following code snippet won't work:

        ::

            import numpy a np
            from pypet.trajectory import Trajectory
            traj = Trajectory()
            traj.f_add_parameter('my_float_parameter', 42.4,
                                 comment='My value is a standard python float')

            traj.f_explore( { 'my_float_parameter': np.arange(42.0, 44.876, 0.23) } )


        This will result in a `TypeError` because your exploration iterable
        `np.arange(42.0, 44.876, 0.23)` contains `numpy.float64` values
        whereas you parameter is supposed to use standard python floats.

        Yet, you can use Numpys `tolist()` function to overcome this problem:

        ::

            traj.f_explore( { 'my_float_parameter': np.arange(42.0, 44.876, 0.23).tolist() } )


        Or you could specify your parameter directly as a numpy float:

        ::

            traj.f_add_parameter('my_float_parameter', np.float64(42.4),
                                   comment='My value is a numpy 64 bit float')



        """
        for run_idx in range(len(self)):
            if self.f_is_completed(run_idx):
                raise TypeError('You cannot explore a trajectory which has been explored before, '
                                'please use `f_expand` instead.')

        added_explored_parameters = []
        try:
            length = len(self)
            for key, builditerable in build_dict.items():
                act_param = self.f_get(key)
                if not act_param.v_is_leaf or not act_param.v_is_parameter:
                    raise ValueError('%s is not an appropriate search string for a parameter.' % key)

                act_param.f_unlock()

                act_param._explore(builditerable)
                added_explored_parameters.append(act_param)

                full_name = act_param.v_full_name
                self._explored_parameters[full_name] = act_param

                act_param._explored = True

                # Compare the length of two consecutive parameters in the `build_dict`
                if len(self._explored_parameters) == 1:
                    length = act_param.f_get_range_length()
                elif not length == act_param.f_get_range_length():
                    raise ValueError('The parameters to explore have not the same size!')

            for irun in range(length):
                self._add_run_info(irun)
            self._test_run_addition(length)

        except Exception:
            # Remove the added parameters again
            for param in added_explored_parameters:
                param.f_unlock()
                param._shrink()
                param._explored = False
                full_name = param.v_full_name
                del self._explored_parameters[full_name]
            if len(self._explored_parameters) == 0:
                self.f_shrink(force=True)
            raise
def f_explore(self, build_dict):
        for run_idx in range(len(self)):
            if self.f_is_completed(run_idx):
                raise TypeError('You cannot explore a trajectory which has been explored before, '
                                'please use `f_expand` instead.')

        added_explored_parameters = []
        try:
            length = len(self)
            for key, builditerable in build_dict.items():
                act_param = self.f_get(key)
                if not act_param.v_is_leaf or not act_param.v_is_parameter:
                    raise ValueError('%s is not an appropriate search string for a parameter.' % key)

                act_param.f_unlock()

                act_param._explore(builditerable)
                added_explored_parameters.append(act_param)

                full_name = act_param.v_full_name
                self._explored_parameters[full_name] = act_param

                act_param._explored = True

                # Compare the length of two consecutive parameters in the `build_dict`
                if len(self._explored_parameters) == 1:
                    length = act_param.f_get_range_length()
                elif not length == act_param.f_get_range_length():
                    raise ValueError('The parameters to explore have not the same size!')

            for irun in range(length):
                self._add_run_info(irun)
            self._test_run_addition(length)

        except Exception:
            # Remove the added parameters again
            for param in added_explored_parameters:
                param.f_unlock()
                param._shrink()
                param._explored = False
                full_name = param.v_full_name
                del self._explored_parameters[full_name]
            if len(self._explored_parameters) == 0:
                self.f_shrink(force=True)
            raise
def f_explore ( self , build_dict ) : for run_idx in range ( len ( self ) ) : if self . f_is_completed ( run_idx ) : raise TypeError ( 'You cannot explore a trajectory which has been explored before, ' 'please use `f_expand` instead.' ) added_explored_parameters = [ ] try : length = len ( self ) for key , builditerable in build_dict . items ( ) : act_param = self . f_get ( key ) if not act_param . v_is_leaf or not act_param . v_is_parameter : raise ValueError ( '%s is not an appropriate search string for a parameter.' % key ) act_param . f_unlock ( ) act_param . _explore ( builditerable ) added_explored_parameters . append ( act_param ) full_name = act_param . v_full_name self . _explored_parameters [ full_name ] = act_param act_param . _explored = True # Compare the length of two consecutive parameters in the `build_dict` if len ( self . _explored_parameters ) == 1 : length = act_param . f_get_range_length ( ) elif not length == act_param . f_get_range_length ( ) : raise ValueError ( 'The parameters to explore have not the same size!' ) for irun in range ( length ) : self . _add_run_info ( irun ) self . _test_run_addition ( length ) except Exception : # Remove the added parameters again for param in added_explored_parameters : param . f_unlock ( ) param . _shrink ( ) param . _explored = False full_name = param . v_full_name del self . _explored_parameters [ full_name ] if len ( self . _explored_parameters ) == 0 : self . f_shrink ( force = True ) raise
Prepares the trajectory to explore the parameter space.


        To explore the parameter space you need to provide a dictionary with the names of the
        parameters to explore as keys and iterables specifying the exploration ranges as values.

        All iterables need to have the same length otherwise a ValueError is raised.
        A ValueError is also raised if the names from the dictionary map to groups or results
        and not parameters.

        If your trajectory is already explored but not stored yet and your parameters are
        not locked you can add new explored parameters to the current ones if their
        iterables match the current length of the trajectory.

        Raises an AttributeError if the names from the dictionary are not found at all in
        the trajectory and NotUniqueNodeError if the keys not unambiguously map
        to single parameters.

        Raises a TypeError if the trajectory has been stored already, please use
        :func:`~pypet.trajectory.Trajectory.f_expand` then instead.

        Example usage:

        >>> traj.f_explore({'groupA.param1' : [1,2,3,4,5], 'groupA.param2':['a','b','c','d','e']})

        Could also be called consecutively:

        >>> traj.f_explore({'groupA.param1' : [1,2,3,4,5]})
        >>> traj.f_explore({'groupA.param2':['a','b','c','d','e']})

        NOTE:

        Since parameters are very conservative regarding the data they accept
        (see :ref:`type_conservation`), you sometimes won't be able to use Numpy arrays
        for exploration as iterables.

        For instance, the following code snippet won't work:

        ::

            import numpy a np
            from pypet.trajectory import Trajectory
            traj = Trajectory()
            traj.f_add_parameter('my_float_parameter', 42.4,
                                 comment='My value is a standard python float')

            traj.f_explore( { 'my_float_parameter': np.arange(42.0, 44.876, 0.23) } )


        This will result in a `TypeError` because your exploration iterable
        `np.arange(42.0, 44.876, 0.23)` contains `numpy.float64` values
        whereas you parameter is supposed to use standard python floats.

        Yet, you can use Numpys `tolist()` function to overcome this problem:

        ::

            traj.f_explore( { 'my_float_parameter': np.arange(42.0, 44.876, 0.23).tolist() } )


        Or you could specify your parameter directly as a numpy float:

        ::

            traj.f_add_parameter('my_float_parameter', np.float64(42.4),
                                   comment='My value is a numpy 64 bit float')
Prepares the trajectory to explore the parameter space .