pyvista.core._validation.check.check_sorted#
- check_sorted(
- array: _ArrayLikeOrScalar[NumberType],
- /,
- *,
- ascending: bool = True,
- strict: bool = False,
- axis: int = -1,
- name: str = 'Array',
Check if an array’s values are sorted.
- Parameters:
- array
float
|ArrayLike
[float
] Number or array to check.
- ascendingbool, default:
True
If
True
, check if the array’s elements are in ascending order. IfFalse
, check if the array’s elements are in descending order.- strictbool, default:
False
If
True
, the array’s elements must be strictly increasing (ifascending=True
) or strictly decreasing (ifascending=False
). Effectively, this means the array must be sorted and its values must be unique.- axis
int
|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.- name
str
, default: “Array” Variable name to use in the error messages if any are raised.
- array
- Raises:
ValueError
If the array is not sorted in ascending order.
See also
Examples
Check if an array’s values are sorted,
>>> from pyvista import _validation >>> _validation.check_sorted([1, 2, 3])