dpnp.array_equal

dpnp.array_equal(a1, a2, equal_nan=False)[source]

True if two arrays have the same shape and elements, False otherwise.

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_nanbool, optional

Whether to compare NaNs 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.

Default: False.

Returns:
outdpnp.ndarray of bool dtype

A 0-d array with True value if the arrays are equal.

See also

dpnp.allclose

Returns True if two arrays are element-wise equal within a tolerance.

dpnp.array_equiv

Returns True if 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_nan is True, complex values with NaN components are considered equal if either the real or the imaginary components are NaNs.

>>> 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)