Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@copydoc(BaseParameter.f_get)
def f_get(self):
if self.f_is_empty():
raise TypeError('Parameter `%s` is empty cannot access data' % self.v_full_name)
self.f_lock() # As soon as someone accesses an entry the parameter gets locked
return self._data
@copydoc(BaseParameter.f_is_empty)
def f_is_empty(self):
"""True if no data has been assigned to the parameter.
Example usage:
>>> param = Parameter('myname.is.example', comment='I am _empty!')
>>> param.f_is_empty()
True
>>> param.f_set(444)
>>> param.f_is_empty()
False
"""
return self._data is None
@copydoc(BaseParameter._set_parameter_access)
def _set_parameter_access(self, idx=0):
if idx >= len(self) and self.f_has_range():
raise ValueError('You try to access data item No. %d in the parameter range, '
'yet there are only %d potential items.' % (idx, len(self)))
elif self.f_has_range():
self._data = self._explored_range[idx]
else:
self._logger.warning('You try to change the access to a parameter range of parameter'
' `%s`. The parameter has no range, your setting has no'
@copydoc(BaseParameter._shrink)
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
@copydoc(BaseParameter._shrink)
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
@copydoc(BaseParameter.f_get_default)
def f_get_default(self):
if self.f_is_empty():
raise TypeError('Parameter `%s` is empty cannot access data' % self.v_full_name)
self.f_lock() # As soon as someone accesses an entry the parameter gets locked
return self._default
@copydoc(BaseParameter.f_get)
def f_get(self):
if self.f_is_empty():
raise TypeError('Parameter `%s` is empty cannot access data' % self.v_full_name)
self.f_lock() # As soon as someone accesses an entry the parameter gets locked
return self._data
@copydoc(Result.f_set_single)
def f_set_single(self, name, item):
if BrianResult.IDENTIFIER in name:
raise AttributeError('Your result name contains the identifier for brian data,'
' please do not use %s in your result names.' %
BrianResult.IDENTIFIER)
elif name == 'storage_mode':
self.v_storage_mode = item
else:
super(BrianResult, self).f_set_single(name, item)
@copydoc(BaseParameter.f_is_empty)
def f_is_empty(self):
"""True if no data has been assigned to the parameter.
Example usage:
>>> param = Parameter('myname.is.example', comment='I am _empty!')
>>> param.f_is_empty()
True
>>> param.f_set(444)
>>> param.f_is_empty()
False
"""
return self._data is None
@copydoc(BaseResult.f_empty)
def f_empty(self):
self._data_ = None