at.lattice.parameters#
Functions
|
Create an array of attributes, which may contain parameters. |
Classes
|
Standalone scalar parameter. |
|
Simulate a numpy array where items may be parameterised. |
- class Param(value, *, name='', conversion=<function _nop>, bounds=None, delta=1.0)[source]#
Bases:
ParamBase,VariableBaseStandalone scalar parameter.
See
VariableBasefor a description of inherited methods- Parameters:
value (Number) – Initial value of the parameter
name (str) – Name of the parameter. If omitted or blank, a unique name is generated.
conversion (Callable[[Any], Any]) – data conversion function
bounds (tuple[Number, Number] | None) – Lower and upper bounds of the parameter value
delta (Number) – Initial variation step.
- set_conversion(conversion)[source]#
Set the data type conversion function.
This method is called when a parameter is assigned to an
Elementattribute. It can only be set once.- Parameters:
conversion (Callable[[Any], Any]) – Function to convert values to the appropriate type
- Raises:
ValueError – If attempting to change an already set conversion function
- class ParamArray(value, shape=(-1, ), dtype=<class 'float'>)[source]#
Bases:
ndarraySimulate a numpy array where items may be parameterised.
This class allows creating arrays that can contain Parameter objects. It provides a value property that returns a numeric array with the current values of all parameters. Changes to the numeric array are propagated back to the parameters.
This is primarily used for element attributes that can be parameterised.
- class ValueArray(parent, dtype=<class 'float'>)[source]#
Bases:
ndarraySubclass of ndarray which reports changes back to its parent ParamArray.
This array is used as the value property of
ParamArray. When items in this array are modified, the changes are propagated back to theParamArrayparent.This is the array obtained with an element get_attribute. It is also the one used when setting an item of an array attribute.
- Parameters:
parent (ParamArray) – The parent ParamArray
dtype (npt.DTypeLike) – Data type of the array.
- Returns:
A new ValueArray instance
- fast_value()[source]#
Numeric array with the current values of all the parameters.
This property returns a
ValueArraythat contains the numeric values of all parameters in the array. Changes to this array are propagated back to theParamArrayparent.- Returns:
A numeric array with the current parameter values
- AttributeArray(value, shape=(-1, ), dtype=<class 'float'>)[source]#
Create an array of attributes, which may contain parameters.
This function creates either a
ParamArray(if the input contains parameters) or a_SafeArray(if the input contains only regular values).- Parameters:
- Returns:
Either a ParamArray or a SafeArray depending on the input