How to use the pypet.pypetexceptions.ParameterLockedException function in pypet

To help you get started, we’ve selected a few pypet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SmokinCaterpillar / pypet / pypet / brian / parameter.py View on Github external
def _load(self, load_dict):
        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self.v_full_name)

        try:
            data_table = load_dict['data' + BrianParameter.IDENTIFIER]

            if 'unit' in data_table:
                self._storage_mode = BrianParameter.FLOAT_MODE
            else:
                self._storage_mode = BrianParameter.STRING_MODE

            if self._storage_mode == BrianParameter.STRING_MODE:
                valstr = data_table['data'][0]

                self._data = eval(valstr)


                if 'explored_data' + BrianParameter.IDENTIFIER in load_dict:
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
def f_set(self, data):

        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self._full_name)

        if self.f_has_range():
            raise AttributeError(
                'Your Parameter is an explored array can no longer change values!')

        if self.v_stored:
            self._logger.debug('You are changing an already stored parameter. If '
                                 'you not explicitly overwrite the data on disk, this change '
                                 'might be lost and not propagated to disk.')

        val = self._convert_data(data)

        if not self.f_supports(val):
            raise TypeError('Unsupported data `%s` of tpye `%s`' % (str(val), str(type(val))))

        self._data = val
github SmokinCaterpillar / pypet / pypet / brian2 / parameter.py View on Github external
def _load(self, load_dict):
        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self.v_full_name)

        try:
            data_table = load_dict['data' + Brian2Parameter.IDENTIFIER]

            unitstring = data_table['unit'][0]
            unit = unit_from_expression(unitstring)
            value = data_table['value'][0]
            self._data = value * unit

            if 'explored_data' + Brian2Parameter.IDENTIFIER in load_dict:
                explore_table = load_dict['explored_data' + Brian2Parameter.IDENTIFIER]

                value_col = explore_table['value']
                explore_list = [value * unit for value in value_col]

                self._explored_range = explore_list
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
the individual data values into a tuple. Thus, the whole exploration range is
        explicitly stored in memory.

        :param explore_iterable: An iterable specifying the exploration range

        For example:

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

        :raises TypeError,ParameterLockedException

        """
        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self.v_full_name)

        if self.f_has_range():
            raise TypeError('Your Parameter %s is already explored, cannot _explore it further!' %
                            self._name)

        data_tuple = self._data_sanity_checks(explore_iterable)

        self._explored_range = data_tuple
        self._explored = True
        self.f_lock()
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
the individual data values into a tuple. Thus, the whole exploration range is
        explicitly stored in memory.

        :param explore_iterable: An iterable specifying the exploration range

        For example:

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

        :raises TypeError,ParameterLockedException

        """
        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self.v_full_name)

        if self.f_has_range():
            raise TypeError('Your parameter `%s` is already explored, '
                            'cannot _explore it further!' % self._name)

        if self._data is None:
            raise TypeError('Your parameter `%s` has no default value, please specify one '
                            'via `f_set` before exploration. ' % self.v_full_name)

        data_list = self._data_sanity_checks(explore_iterable)

        self._explored_range = data_list
        self._explored = True
        self.f_lock()
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
:param explore_iterable: An iterable specifying the exploration range

         For example:

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

        :raises TypeError, ParameterLockedException

        """
        if self.v_locked:
            raise pex.ParameterLockedException('Parameter `%s` is locked!' % self.v_full_name)

        if not self.f_has_range():
            raise TypeError('Your Parameter `%s` is not an array and can therefore '
                            'not be expanded.' % self._name)

        data_tuple = self._data_sanity_checks(explore_iterable)

        self._explored_range = self._explored_range + data_tuple
        self.f_lock()
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
def _shrink(self):

        if self.v_locked:
            raise pex.ParameterLockedException('Parameter %s is locked!' % self.v_full_name)

        if not self.f_has_range():
            raise TypeError('Cannot shrink Parameter without a range.')

        if self.f_is_empty():
            raise TypeError('Cannot shrink empty Parameter.')

        del self._explored_range
        self._explored_range = {}
        self._explored = False
github SmokinCaterpillar / pypet / pypet / parameter.py View on Github external
def f_empty(self):

        if self.v_locked:
            raise pex.ParameterLockedException('Parameter %s is locked!' % self.v_full_name)

        if self.f_has_range():
            self._shrink()

        del self._data
        del self._default
        self._data = None
        self._default = None
        self._explored = False