xp_assert_less¶
- xp_assert_less(actual, desired, *, check_namespace=True, check_dtype=True, check_shape=True, check_0d=True, err_msg='', verbose=True, xp: ModuleType | None = None)[source][source]¶
- Assert that all elements of an array are strictly less than another
array.
- Parameters:
actual (
array_like) – The array to test.desired (
array_like) – The array to compare against.check_namespace (
bool, optional) – If True, check that the arrays have the same namespace.check_dtype (
bool, optional) – If True, check that the arrays have the same dtype.check_shape (
bool, optional) – If True, check that the arrays have the same shape.check_0d (
bool, optional) – If True, check that the arrays have the same dimensionality.err_msg (
str, optional) – The error message to be printed in case of failure.verbose (
bool, optional) – If True, print arrays that are not less.xp (
module, optional) –- The array API namespace to use. If not provided, the namespace is
inferred from the arrays.
- Returns:
- If all elements of
actualare strictly less than all elements of desired, otherwise raises an AssertionError.
- If all elements of
- Return type:
Notes
- This function is a wrapper around the testing functions of different array
- libraries, providing a consistent interface for comparison testing across
different backends.
Examples
>>> import numpy as np >>> a = np.array([1, 2, 3]) >>> b = np.array([4, 5, 6]) >>> xp_assert_less(a, b) # No error raised >>> c = np.array([3, 4, 2]) >>> xp_assert_less(a, c) Traceback (most recent call last): ... AssertionError: Arrays are not less