dpnp.array_equal
- dpnp.array_equal(a1, a2, equal_nan=False)[source]
Trueif two arrays have the same shape and elements,Falseotherwise.For full documentation refer to
numpy.array_equal.- Parameters:
a1 ({dpnp.ndarray, usm_ndarray, scalar}) -- First input array.
a2 ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array.
equal_nan (bool, optional) --
Whether to compare
NaNsas 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 isNaN.Default:
False.
- Returns:
out -- A 0-d array with
Truevalue if the arrays are equal.- Return type:
dpnp.ndarray of bool dtype
See also
dpnp.allcloseReturns
Trueif two arrays are element-wise equal within a tolerance.dpnp.array_equivReturns
Trueif input arrays are shape consistent and all elements equal.
Notes
At least one of x1 or x2 must be an array.
Examples
>>> import dpnp as np >>> a = np.array([1, 2]) >>> b = np.array([1, 2]) >>> np.array_equal(a, b) array(True)
>>> b = np.array([1, 2, 3]) >>> np.array_equal(a, b) array(False)
>>> b = np.array([1, 4]) >>> np.array_equal(a, b) array(False)
>>> a = np.array([1, np.nan]) >>> np.array_equal(a, a) array(False)
>>> np.array_equal(a, a, equal_nan=True) array(True)
When
equal_nanisTrue, complex values with NaN components are considered equal if either the real or the imaginary components areNaNs.>>> a = np.array([1 + 1j]) >>> b = a.copy() >>> a.real = np.nan >>> b.imag = np.nan >>> np.array_equal(a, b, equal_nan=True) array(True)