MCPcopy Index your code
hub / github.com/pytorch/pytorch / assert_array_less

Function assert_array_less

torch/_numpy/testing/utils.py:953–1038  ·  view source on GitHub ↗

Raises an AssertionError if two array_like objects are not ordered by less than. Given two array_like objects, check that the shape is equal and all elements of the first object are strictly smaller than those of the second object. An exception is raised at shape mismatch or in

(x, y, err_msg="", verbose=True)

Source from the content-addressed store, hash-verified

951
952
953def assert_array_less(x, y, err_msg="", verbose=True):
954 """
955 Raises an AssertionError if two array_like objects are not ordered by less
956 than.
957
958 Given two array_like objects, check that the shape is equal and all
959 elements of the first object are strictly smaller than those of the
960 second object. An exception is raised at shape mismatch or incorrectly
961 ordered values. Shape mismatch does not raise if an object has zero
962 dimension. In contrast to the standard usage in numpy, NaNs are
963 compared, no assertion is raised if both objects have NaNs in the same
964 positions.
965
966
967
968 Parameters
969 ----------
970 x : array_like
971 The smaller object to check.
972 y : array_like
973 The larger object to compare.
974 err_msg : string
975 The error message to be printed in case of failure.
976 verbose : bool
977 If True, the conflicting values are appended to the error message.
978
979 Raises
980 ------
981 AssertionError
982 If actual and desired objects are not equal.
983
984 See Also
985 --------
986 assert_array_equal: tests objects for equality
987 assert_array_almost_equal: test objects for equality up to precision
988
989
990
991 Examples
992 --------
993 >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1.1, 2.0, np.nan])
994 >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1, 2.0, np.nan])
995 Traceback (most recent call last):
996 ...
997 AssertionError:
998 Arrays are not less-ordered
999 <BLANKLINE>
1000 Mismatched elements: 1 / 3 (33.3%)
1001 Max absolute difference: 1.0
1002 Max relative difference: 0.5
1003 x: torch.ndarray([1., 1., nan], dtype=float64)
1004 y: torch.ndarray([1., 2., nan], dtype=float64)
1005
1006 >>> np.testing.assert_array_less([1.0, 4.0], 3)
1007 Traceback (most recent call last):
1008 ...
1009 AssertionError:
1010 Arrays are not less-ordered

Callers 2

test_partitionMethod · 0.90
assert_partitionedMethod · 0.90

Calls 1

assert_array_compareFunction · 0.85

Tested by 2

test_partitionMethod · 0.72
assert_partitionedMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…