pyvista.core._validation.check.check_range

Contents

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',
) None[source]#

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

Parameters:
arrayfloat | ArrayLike[float]

Number or array to check.

rngVectorLike[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. 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])