pyvista.core._validation.check.check_sorted

Contents

pyvista.core._validation.check.check_sorted#

check_sorted(
array: _ArrayLikeOrScalar[NumberType],
/,
*,
ascending: bool = True,
strict: bool = False,
axis: int = -1,
name: str = 'Array',
)[source]#

Check if an array’s values are sorted.

Parameters:
arrayfloat | ArrayLike[float]

Number or array to check.

ascendingbool, default: True

If True, check if the array’s elements are in ascending order. If False, check if the array’s elements are in descending order.

strictbool, default: False

If True, the array’s elements must be strictly increasing (if ascending=True) or strictly decreasing (if ascending=False). Effectively, this means the array must be sorted and its values must be unique.

axisint | None, default: -1

Axis along which to check sorting. If None, the array is flattened before checking. The default is -1, which checks sorting along the last axis.

namestr, default: “Array”

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

Raises:
ValueError

If the array is not sorted in ascending order.

See also

check_range

Examples

Check if an array’s values are sorted,

>>> from pyvista import _validation
>>> _validation.check_sorted([1, 2, 3])