CADETProcess.dataStructure.parameter.Ranged#
- class CADETProcess.dataStructure.parameter.Ranged(*args, lb=-inf, lb_op=<built-in function lt>, ub=inf, ub_op=<built-in function gt>, **kwargs)[source]#
Descriptor for parameters within specified bounds.
Allows setting values constrained by provided lower and upper bounds. The actual comparisons against the bounds can be customized using the lb_op and ub_op comparison functions.
See also
Notes
By default, values are checked to be strictly within the bounds (exclusive). To change this behavior, use the lb_op and ub_op parameters.
The check_range method can be overridden for custom range validation logic, especially if the data structure isn’t a simple scalar value (e.g. for np.ndarrays).
Examples
Constraining a parameter between 0 and 10:
>>> class MyClass: ... value = Ranged(lb=0, ub=10) ... >>> obj = MyClass() >>> obj.value = 5 # This is valid >>> obj.value = -5 # Raises an error
- Attributes:
- lbnumeric
The lower bound of the parameter. Default is negative infinity.
- lb_opcallable
A callable that defines the comparison operation against the lower bound. Default is less than (<).
- ubnumeric
The upper bound of the parameter. Default is positive infinity.
- ub_opcallable
A callable that defines the comparison operation against the upper bound. Default is greater than (>).
Methods
check_range
(value)Validate if the value is within the defined range.
get_default_value
(instance)Return default values if necessary.