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. Both inputs x1 and x2 can not be scalars at the same time.

  • a2 ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array. Both inputs x1 and x2 can not be scalars at the same time.

  • equal_nan (bool, 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:

b -- An array with a data type of bool. Returns True if the arrays are equal.

Return type:

dpnp.ndarray

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.

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)