MCPcopy Create free account
hub / github.com/numpy/numpy / allequal

Function allequal

numpy/ma/core.py:8038–8093  ·  view source on GitHub ↗

Return True if all entries of a and b are equal, using fill_value as a truth value where either or both are masked. Parameters ---------- a, b : array_like Input arrays to compare. fill_value : bool, optional Whether masked values in a or b are considered eq

(a, b, fill_value=True)

Source from the content-addressed store, hash-verified

8036
8037
8038def allequal(a, b, fill_value=True):
8039 """
8040 Return True if all entries of a and b are equal, using
8041 fill_value as a truth value where either or both are masked.
8042
8043 Parameters
8044 ----------
8045 a, b : array_like
8046 Input arrays to compare.
8047 fill_value : bool, optional
8048 Whether masked values in a or b are considered equal (True) or not
8049 (False).
8050
8051 Returns
8052 -------
8053 y : bool
8054 Returns True if the two arrays are equal within the given
8055 tolerance, False otherwise. If either array contains NaN,
8056 then False is returned.
8057
8058 See Also
8059 --------
8060 all, any
8061 numpy.ma.allclose
8062
8063 Examples
8064 --------
8065 >>> a = np.ma.array([1e10, 1e-7, 42.0], mask=[0, 0, 1])
8066 >>> a
8067 masked_array(data=[10000000000.0, 1e-07, --],
8068 mask=[False, False, True],
8069 fill_value=1e+20)
8070
8071 >>> b = np.array([1e10, 1e-7, -42.0])
8072 >>> b
8073 array([ 1.00000000e+10, 1.00000000e-07, -4.20000000e+01])
8074 >>> np.ma.allequal(a, b, fill_value=False)
8075 False
8076 >>> np.ma.allequal(a, b)
8077 True
8078
8079 """
8080 m = mask_or(getmask(a), getmask(b))
8081 if m is nomask:
8082 x = getdata(a)
8083 y = getdata(b)
8084 d = umath.equal(x, y)
8085 return d.all()
8086 elif fill_value:
8087 x = getdata(a)
8088 y = getdata(b)
8089 d = umath.equal(x, y)
8090 dm = array(d, mask=m, copy=False)
8091 return dm.filled(True).all(None)
8092 else:
8093 return False
8094
8095

Callers 5

test_matrix_indexingMethod · 0.90
test_testCIMethod · 0.90
test_testCopySizeMethod · 0.90
test_indexingMethod · 0.90
test_copyMethod · 0.90

Calls 6

mask_orFunction · 0.85
getmaskFunction · 0.85
getdataFunction · 0.85
arrayFunction · 0.70
allMethod · 0.45
filledMethod · 0.45

Tested by 5

test_matrix_indexingMethod · 0.72
test_testCIMethod · 0.72
test_testCopySizeMethod · 0.72
test_indexingMethod · 0.72
test_copyMethod · 0.72