pyvista_validation.check.check_sorted

Contents

pyvista_validation.check.check_sorted#

pyvista_validation.check.check_sorted(array, *, ascending=True, strict=False, axis=-1, name='Array')#

Check if an array’s values are sorted.

Parameters:
arrayfloat | ArrayLikeFloat

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.

Returns:
array_like

The input, unchanged.

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_validation import check_sorted
>>> check_sorted([1, 2, 3])
[1, 2, 3]