MCPcopy
hub / github.com/numpy/numpy / almost

Function almost

numpy/ma/testutils.py:69–87  ·  view source on GitHub ↗

Returns True if a and b are equal up to decimal places. If fill_value is True, masked values considered equal. Otherwise, masked values are considered unequal.

(a, b, decimal=6, fill_value=True)

Source from the content-addressed store, hash-verified

67
68
69def almost(a, b, decimal=6, fill_value=True):
70 """
71 Returns True if a and b are equal up to decimal places.
72
73 If fill_value is True, masked values considered equal. Otherwise,
74 masked values are considered unequal.
75
76 """
77 m = mask_or(getmask(a), getmask(b))
78 d1 = filled(a)
79 d2 = filled(b)
80 if d1.dtype.char == "O" or d2.dtype.char == "O":
81 return np.equal(d1, d2).ravel()
82 x = filled(
83 masked_array(d1, copy=False, mask=m), fill_value
84 ).astype(np.float64)
85 y = filled(masked_array(d2, copy=False, mask=m), 1).astype(np.float64)
86 d = np.around(np.abs(x - y), decimal) <= 10.0 ** (-decimal)
87 return d.ravel()
88
89
90def _assert_equal_on_sequences(actual, desired, err_msg=''):

Callers 1

compareFunction · 0.85

Calls 5

mask_orFunction · 0.85
getmaskFunction · 0.85
filledFunction · 0.85
astypeMethod · 0.80
ravelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…