MCPcopy
hub / github.com/numpy/numpy / allequal

Function allequal

numpy/ma/core.py:8458–8514  ·  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

8456
8457
8458def allequal(a, b, fill_value=True):
8459 """
8460 Return True if all entries of a and b are equal, using
8461 fill_value as a truth value where either or both are masked.
8462
8463 Parameters
8464 ----------
8465 a, b : array_like
8466 Input arrays to compare.
8467 fill_value : bool, optional
8468 Whether masked values in a or b are considered equal (True) or not
8469 (False).
8470
8471 Returns
8472 -------
8473 y : bool
8474 Returns True if the two arrays are equal within the given
8475 tolerance, False otherwise. If either array contains NaN,
8476 then False is returned.
8477
8478 See Also
8479 --------
8480 all, any
8481 numpy.ma.allclose
8482
8483 Examples
8484 --------
8485 >>> import numpy as np
8486 >>> a = np.ma.array([1e10, 1e-7, 42.0], mask=[0, 0, 1])
8487 >>> a
8488 masked_array(data=[10000000000.0, 1e-07, --],
8489 mask=[False, False, True],
8490 fill_value=1e+20)
8491
8492 >>> b = np.array([1e10, 1e-7, -42.0])
8493 >>> b
8494 array([ 1.00000000e+10, 1.00000000e-07, -4.20000000e+01])
8495 >>> np.ma.allequal(a, b, fill_value=False)
8496 False
8497 >>> np.ma.allequal(a, b)
8498 True
8499
8500 """
8501 m = mask_or(getmask(a), getmask(b))
8502 if m is nomask:
8503 x = getdata(a)
8504 y = getdata(b)
8505 d = umath.equal(x, y)
8506 return d.all()
8507 elif fill_value:
8508 x = getdata(a)
8509 y = getdata(b)
8510 d = umath.equal(x, y)
8511 dm = array(d, mask=m, copy=False)
8512 return dm.filled(True).all(None)
8513 else:
8514 return False
8515

Callers 6

test_matrix_indexingMethod · 0.90
test_testCIMethod · 0.90
test_testCopySizeMethod · 0.90
test_indexingMethod · 0.90
test_copyMethod · 0.90
test_allequalMethod · 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 6

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…