pyvista.core._validation.check.check_range#
- check_range(
- array: _ArrayLikeOrScalar[NumberType],
- /,
- rng: VectorLike[_NumberType],
- *,
- strict_lower: bool = False,
- strict_upper: bool = False,
- name: str = 'Array',
Check if an array’s values are all within a specific range.
- Parameters:
- array
float
|ArrayLike
[float
] Number or array to check.
- rng
VectorLike
[float
],optional
Vector with two elements
[min, max]
specifying the minimum and maximum data values allowed, respectively. By default, the range endpoints are inclusive, i.e. values must be >= min and <= max. Usestrict_lower
and/orstrict_upper
to further restrict the allowable range. Usenp.inf
or-np.inf
to specify open intervals, e.g.[0, np.inf]
.- strict_lowerbool, default:
False
Enforce a strict lower bound for the range, i.e. array values must be strictly greater than the minimum.
- strict_upperbool, default:
False
Enforce a strict upper bound for the range, i.e. array values must be strictly less than the maximum.
- name
str
, default: “Array” Variable name to use in the error messages if any are raised.
- array
- 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 import _validation >>> _validation.check_range([0, 0.5, 1], rng=[0, 1])