Parameter
- class sherpa.models.parameter.Parameter(modelname: str, name: str, val: SupportsFloat, min: SupportsFloat = -3.4028234663852886e+38, max: SupportsFloat = 3.4028234663852886e+38, hard_min: SupportsFloat = -3.4028234663852886e+38, hard_max: SupportsFloat = 3.4028234663852886e+38, units: str = '', frozen: bool = False, alwaysfrozen: bool = False, hidden: bool = False, aliases: Sequence[str] | None = None)[source] [edit on github]
Bases:
NoNewAttributesAfterInitRepresent 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, max, hard_min, hard_max: number, optional
The soft and hard limits for the parameter value.
- units
str,optional The units for the parameter value.
- frozenbool,
optional Does the parameter default to being frozen?
- alwaysfrozenbool,
optional If set then the parameter can never be thawed.
- hiddenbool,
optional Should the parameter be included when displaying the model contents?
- aliases
Noneorlistofstr If not None then alternative names for the parameter (these are expected to be matched in a case-insensitive manner).
- modelname
- Attributes:
alwaysfrozenIs the parameter always frozen?
- default_max
- default_min
default_valThe default value of the parameter.
frozenIs the parameter currently frozen?
hard_maxThe hard maximum of the parameter.
hard_minThe hard minimum of the parameter.
linkThe link expression to other parameters, if set.
maxThe maximum value of the parameter.
minThe minimum value of the parameter.
valThe current value of the parameter.
Methods
freeze()Set the
frozenattribute 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
frozenattribute for the parameter.unlink()Remove any link to other parameters.
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
frozenattribute 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
frozenattribute 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
alwaysfrozenset 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 >>> print(a.val) 2.0 >>> print(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.
- numpy_binop_with_symbols = {<ufunc 'add'>: '+', <ufunc 'divide'>: '/', <ufunc 'floor_divide'>: '//', <ufunc 'multiply'>: '*', <ufunc 'power'>: '**', <ufunc 'remainder'>: '%', <ufunc 'subtract'>: '-'}
- val
The current value of the parameter.
If the parameter is a link then it is possible that accessing the value will raise a ParameterErr in cases where the link expression falls outside the soft limits of the parameter.
See also
default_val,link,max,min
Methods Documentation
- freeze() None[source] [edit on github]
Set the
frozenattribute for the parameter.
- reset() None[source] [edit on github]
Reset the parameter value and limits to their default values.
- set(val: SupportsFloat | None = None, min: SupportsFloat | None = None, max: SupportsFloat | None = None, frozen: bool | None = None, default_val: SupportsFloat | None = None, default_min: SupportsFloat | None = None, default_max: SupportsFloat | None = None) None[source] [edit on github]
Change a parameter setting.
- Parameters:
- val
numberorNone,optional The new parameter value.
- min, max
numberorNone,optional The new parameter range.
- frozenbool or
None,optional Should the frozen flag be set?
- default_val
numberorNone,optional The new default parameter value.
- default_min, default_max
numberorNone,optional The new default parameter limits.
- val
- thaw() None[source] [edit on github]
Unset the
frozenattribute for the parameter.- Raises:
ParameterErrThe parameter is marked as always frozen.
- unlink() None[source] [edit on github]
Remove any link to other parameters.