MCPcopy
hub / github.com/numpy/numpy / func_assert_same_pos

Function func_assert_same_pos

numpy/testing/_private/utils.py:777–806  ·  view source on GitHub ↗

Handling nan/inf. Combine results of running func on x and y, checking that they are True at the same locations.

(x, y, func=isnan, hasval='nan')

Source from the content-addressed store, hash-verified

775 return result.all() != True
776
777 def func_assert_same_pos(x, y, func=isnan, hasval='nan'):
778 """Handling nan/inf.
779
780 Combine results of running func on x and y, checking that they are True
781 at the same locations.
782
783 """
784 __tracebackhide__ = True # Hide traceback for py.test
785
786 x_id = func(x)
787 y_id = func(y)
788 if robust_any_difference(x_id, y_id):
789 msg = build_err_msg(
790 [x, y],
791 err_msg + f'\n{hasval} location mismatch:',
792 verbose=verbose, header=header,
793 names=names,
794 precision=precision)
795 raise AssertionError(msg)
796 # If there is a scalar, then here we know the array has the same
797 # flag as it everywhere, so we should return the scalar flag.
798 # np.ma.masked is also handled and converted to np.False_ (even if the other
799 # array has nans/infs etc.; that's OK given the handling later of fully-masked
800 # results).
801 if isinstance(x_id, bool) or x_id.ndim == 0:
802 return np.bool(x_id)
803 elif isinstance(y_id, bool) or y_id.ndim == 0:
804 return np.bool(y_id)
805 else:
806 return y_id
807
808 def assert_same_inf_values(x, y, infs_mask):
809 """

Callers 1

assert_array_compareFunction · 0.85

Calls 3

robust_any_differenceFunction · 0.85
build_err_msgFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…