array_equal#

ivy.array_equal(x0, x1, /)[source]#

Determine whether two input arrays are equal across all elements.

Parameters:
  • x0 (Union[Array, NativeArray]) – The first input array to compare.

  • x1 (Union[Array, NativeArray]) – The second input array to compare.

Return type:

bool

Returns:

ret – Boolean, whether or not the input arrays are equal across all elements.

Examples

>>> x = ivy.array([1,0,1])
>>> y = ivy.array([1,0,-1])
>>> z = ivy.array_equal(x,y)
>>> print(z)
False
>>> a = ivy.array([1, 2])
>>> b = ivy.array([1, 2])
>>> c = ivy.array_equal(a,b)
>>> print(c)
True
>>> i = ivy.array([1, 2])
>>> j = ivy.array([1, 2, 3])
>>> k = ivy.array_equal(i,j)
>>> print(k)
False
Array.array_equal(self, x, /)#

ivy.Array instance method variant of ivy.array_equal. This method simply wraps the function, and so the docstring for ivy.array_equal also applies to this method with minimal changes.

Parameters:
  • self (Array) – input array

  • x (Union[Array, NativeArray]) – input array to compare to self

Return type:

bool

Returns:

ret – Boolean, whether or not the input arrays are equal

Examples

>>> x = ivy.array([-1,0])
>>> y = ivy.array([1,0])
>>> z = x.array_equal(y)
>>> print(z)
False
>>> a = ivy.array([1, 2])
>>> b = ivy.array([1, 2])
>>> c = a.array_equal(b)
>>> print(c)
True
Container.array_equal(self, x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)#

ivy.Container instance method variant of ivy.array_equal. This method simply wraps the function, and so the docstring for ivy.array_equal also applies to this method with minimal changes.

Parameters:
  • self (Union[Array, NativeArray, Container]) – The first input container to compare.

  • x (Union[Array, NativeArray, Container]) – The second input container to compare.

  • key_chains (Optional[Union[List[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

  • to_apply (bool) – If True, the method will be applied to key_chains, otherwise key_chains (default: True) will be skipped. Default is True.

  • prune_unapplied (bool) – Whether to prune key_chains for which the function was not applied. (default: False) Default is False.

  • map_sequences (bool) – Whether to also map method to sequences (lists, tuples). (default: False) Default is False.

Return type:

Container

Returns:

ret – A boolean container indicating whether the two containers are equal at each level.

Examples

>>> a = ivy.array([[0., 1.], [1. ,0.]])
>>> b = ivy.array([[-2., 1.], [1. ,2.]])
>>> c = ivy.array([[0., 1.], [1. ,0.]])
>>> d = ivy.array([[2., 1.], [1. ,2.]])
>>> a0 = ivy.Container(a = a, b = b)
>>> a1 = ivy.Container(a = c, b = d)
>>> y = a0.array_equal(a1)
>>> print(y)
{
    a: true,
    b: false
}