Parameter
- class sherpa.models.parameter.Parameter(modelname, name, val, min=- 3.4028234663852886e+38, max=3.4028234663852886e+38, hard_min=- 3.4028234663852886e+38, hard_max=3.4028234663852886e+38, units='', frozen=False, alwaysfrozen=False, hidden=False, aliases=None)[source] [edit on github]
Bases:
NoNewAttributesAfterInit
Represent a model parameter.
- Parameters:
modelname (str) – The name of the model component containing the parameter.
name (str) – The name of the parameter. It should be considered to be matched in a case-insensitive manner.
val (number) – The default value for the parameter.
min (number, optional) – The soft and hard limits for the parameter value.
max (number, optional) – The soft and hard limits for the parameter value.
hard_min (number, optional) – The soft and hard limits for the parameter value.
hard_max (number, optional) – The soft and hard limits for the parameter value.
units (str, optional) – The units for the parameter value.
frozen (bool, optional) – Does the parameter default to being frozen?
alwaysfrozen (bool, optional) – If set then the parameter can never be thawed.
hidden (bool, optional) – Should the parameter be included when displaying the model contents?
aliases (None or list of str) – If not None then alternative names for the parameter (these are expected to be matched in a case-insensitive manner).
Attributes Summary
Is the parameter always frozen?
The default value of the parameter.
Is the parameter currently frozen?
The hard maximum of the parameter.
The hard minimum of the parameter.
The link expression to other parameters, if set.
The maximum value of the parameter.
The minimum value of the parameter.
The current value of the parameter.
Methods Summary
freeze
()Set the
frozen
attribute for the parameter.reset
()Reset the parameter value and limits to their default values.
set
([val, min, max, frozen, default_val, ...])Change a parameter setting.
thaw
()Unset the
frozen
attribute for the parameter.unlink
()Remove any link to other parameters.
Attributes Documentation
- alwaysfrozen
Is the parameter always frozen?
- default_max
- default_min
- frozen
Is the parameter currently frozen?
Those parameters created with
alwaysfrozen
set can not be changed.See also
- link
The link expression to other parameters, if set.
The link expression defines if the parameter is not a free parameter but is actually defined in terms of other parameters.
See also
Examples
>>> a = Parameter("mdl", "a", 2) >>> b = Parameter("mdl", "b", 1) >>> b.link = 10 - a >>> a.val 2.0 >>> b.val 8.0
- max
The maximum value of the parameter.
The maximum must lie between the hard_min and hard_max limits.
- min
The minimum value of the parameter.
The minimum must lie between the hard_min and hard_max limits.
- val
The current value of the parameter.
If the parameter is a link then it is possible that accessing the value will raise a ParamaterErr in cases where the link expression falls outside the soft limits of the parameter.
See also
default_val
,link
,max
,min
Methods Documentation
- freeze()[source] [edit on github]
Set the
frozen
attribute for the parameter.See also
- reset()[source] [edit on github]
Reset the parameter value and limits to their default values.
- set(val=None, min=None, max=None, frozen=None, default_val=None, default_min=None, default_max=None)[source] [edit on github]
Change a parameter setting.
- Parameters:
val (number or None, optional) – The new parameter value.
min (number or None, optional) – The new parameter range.
max (number or None, optional) – The new parameter range.
frozen (bool or None, optional) – Should the frozen flag be set?
default_val (number or None, optional) – The new default parameter value.
default_min (number or None, optional) – The new default parameter limits.
default_max (number or None, optional) – The new default parameter limits.
- thaw()[source] [edit on github]
Unset the
frozen
attribute for the parameter.See also
- unlink()[source] [edit on github]
Remove any link to other parameters.