pyvista_validation.check.check_range#
- pyvista_validation.check.check_range(array, /, rng, *, strict_lower=False, strict_upper=False, name='Array')#
Check if an array’s values are all within a specific range.
- Parameters:
- arrayfloat | ArrayLikeFloat
Number or array to check.
- rngVectorLikeFloat, optional
Vector with two elements
[min, max]specifying the minimum and maximum data values allowed, respectively. By default, the range endpoints are inclusive, that is, values must be >= min and <= max. Usestrict_lowerand/orstrict_upperto further restrict the allowable range. Usenp.infor-np.infto specify open intervals, e.g.[0, np.inf].- strict_lowerbool, default: False
Enforce a strict lower bound for the range, that is, array values must be strictly greater than the minimum.
- strict_upperbool, default: False
Enforce a strict upper bound for the range, that is, array values must be strictly less than the maximum.
- namestr, default: “Array”
Variable name to use in the error messages if any are raised.
- Returns:
- array_like
The input, unchanged.
- Raises:
- ValueError
If any array value is outside the specified range.
See also
Examples
Check if an array’s values are in the range ``[0, 1]`.
>>> from pyvista_validation import check_range >>> check_range([0, 0.5, 1], rng=[0, 1]) [0, 0.5, 1]