CADETProcess.dataStructure.parameter.RangedArray#
- class CADETProcess.dataStructure.parameter.RangedArray(*args, lb=-inf, lb_op=<built-in function lt>, ub=inf, ub_op=<built-in function gt>, **kwargs)[source]#
Parameter descriptor for arrays with elements constrained within some bounds.
This class extends the Ranged descriptor to support array-like structures (lists, numpy arrays, etc.). Each element in the array is individually checked against the specified bounds.
See also
Notes
The class uses numpy for efficient element-wise comparison.
In case of out-of-bound values, the raised exception specifies the index/indices of such values.
Examples
Constraining elements of an array parameter between 0 and 10:
>>> class MyClass: ... values = RangedArray(lb=0, ub=10) ... >>> obj = MyClass() >>> obj.values = [5, 7, 2] # This is valid >>> obj.values = [5, -1, 2] # Raises an error indicating the second element is below the lower bound.
- Attributes:
default
Any: Get or set the default value of the parameter.
Methods
check_range
(value)Check each element of an array-like structure against specified bounds.
get_default_value
(instance)Return default values if necessary.