plima.utils.validators#
Validation helpers for numerical inputs.
Functions
|
Return values as a finite NumPy float array. |
|
Return values as a NumPy float array. |
|
Check that all values are finite. |
|
Check that all values are fractions between zero and one. |
|
Check that all values are greater than a threshold. |
|
Check that all values are non negative. |
|
Check that all values are positive. |
- plima.utils.validators.as_finite_float_array(values, *, name)[source]#
Return values as a finite NumPy float array.
- Parameters:
values (ArrayLike) – Input values to convert and check.
name (str) – Name of the input used in error messages.
- Returns:
Input values converted to a finite float array.
- Raises:
ValueError – If any value is not finite.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- plima.utils.validators.as_float_array(values, *, name)[source]#
Return values as a NumPy float array.
- Parameters:
values (ArrayLike) – Input values to convert.
name (str) – Name of the input used in error messages.
- Returns:
Input values converted to a float array.
- Raises:
ValueError – If the input cannot be converted to floats.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- plima.utils.validators.validate_finite(values, *, name)[source]#
Check that all values are finite.
- Parameters:
values (ArrayLike) – Input values to check.
name (str) – Name of the input used in error messages.
- Raises:
ValueError – If any value is NaN or infinite.
- Return type:
None
- plima.utils.validators.validate_fraction(values, *, name)[source]#
Check that all values are fractions between zero and one.
- Parameters:
values (ArrayLike) – Input values to check.
name (str) – Name of the input used in error messages.
- Raises:
ValueError – If any value is outside the closed interval from zero to one.
- Return type:
None
- plima.utils.validators.validate_greater_than(values, *, threshold, name)[source]#
Check that all values are greater than a threshold.
- Parameters:
values (ArrayLike) – Input values to check.
threshold (float) – Lower allowed bound.
name (str) – Name of the input used in error messages.
- Raises:
ValueError – If any value is less than or equal to
threshold.- Return type:
None