pyvista.core._validation.check.check_range#

check_range(arr, /, rng, *, strict_lower=False, strict_upper=False, name='Array')[source]#

Check if an array’s values are all within a specific range.

Parameters:
arrarray_like

Array to check.

rngarray_like[float, float], optional

Array-like 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. Use strict_lower and/or strict_upper to further restrict the allowable range. Use np.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.

namestr, default: “Array”

Variable name to use in the error messages if any are raised.

Raises:
ValueError

If any array value is outside the specified range.

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])