bundles / numpy 2.4.4 / numpy / array_equal
_ArrayFunctionDispatcher
numpy:array_equal
source: /numpy/_core/numeric.py :2535
Signature
def array_equal ( a1 , a2 , equal_nan = False ) Summary
True if two arrays have the same shape and elements, False otherwise.
Parameters
a1, a2: array_likeInput arrays.
equal_nan: boolWhether to compare NaN's as equal. If the dtype of a1 and a2 is complex, values will be considered equal if either the real or the imaginary component of a given value is
nan.
Returns
b: boolReturns True if the arrays are equal.
Examples
import numpy as np
✓np.array_equal([1, 2], [1, 2])
✓np.array_equal(np.array([1, 2]), np.array([1, 2]))
✓np.array_equal([1, 2], [1, 2, 3])
✓np.array_equal([1, 2], [1, 4])
✓a = np.array([1, np.nan]) np.array_equal(a, a)✓
np.array_equal(a, a, equal_nan=True)
✓a = np.array([1 + 1j]) b = a.copy() a.real = np.nan b.imag = np.nan np.array_equal(a, b, equal_nan=True)✓
See also
- allclose
Returns True if two arrays are element-wise equal within a tolerance.
- array_equiv
Returns True if input arrays are shape consistent and all elements equal.
Aliases
-
numpy.array_equal