MCPcopy
hub / github.com/numpy/numpy / robust_any_difference

Function robust_any_difference

numpy/testing/_private/utils.py:759–775  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

757 return x.dtype.char == "T"
758
759 def robust_any_difference(x, y):
760 # We include work-arounds here to handle three types of slightly
761 # pathological ndarray subclasses:
762 # (1) all() on fully masked arrays returns np.ma.masked, so we use != True
763 # (np.ma.masked != True evaluates as np.ma.masked, which is falsy).
764 # (2) __eq__ on some ndarray subclasses returns Python booleans
765 # instead of element-wise comparisons, so we cast to np.bool() in
766 # that case (or in case __eq__ returns some other value with no
767 # all() method).
768 # (3) subclasses with bare-bones __array_function__ implementations may
769 # not implement np.all(), so favor using the .all() method
770 # We are not committed to supporting cases (2) and (3), but it's nice to
771 # support them if possible.
772 result = x == y
773 if not hasattr(result, "all") or not callable(result.all):
774 result = np.bool(result)
775 return result.all() != True
776
777 def func_assert_same_pos(x, y, func=isnan, hasval='nan'):
778 """Handling nan/inf.

Callers 2

func_assert_same_posFunction · 0.85
assert_same_inf_valuesFunction · 0.85

Calls 1

allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…