Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformatted array_equal #23058

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ivy/data_classes/array/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ def array_equal(self: ivy.Array, x: Union[ivy.Array, ivy.NativeArray], /) -> boo
>>> c = a.array_equal(b)
>>> print(c)
True

>>> i = ivy.array([1, 2])
>>> j = ivy.array([1, 2, 3])
>>> k = i.array_equal(j)
>>> print(k)
False
"""
return ivy.array_equal(self, x)

Expand Down
17 changes: 14 additions & 3 deletions ivy/data_classes/container/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -4031,14 +4031,25 @@ def array_equal(
>>> 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)
>>> a1 = ivy.Container(a = a, b = b)
>>> a2 = ivy.Container(a = c, b = d)
>>> y = a1.array_equal(a2)
>>> print(y)
{
a: True,
b: False
}

>>> x1 = ivy.Container(a=ivy.native_array([1, 0, 0]),
b=ivy.array([1, 2, 3]))
>>> x2 = ivy.Container(a=ivy.native_array([1, 0, 1]),
b=ivy.array([1, 2, 3]))
>>> y = x1.array_equal(x2)
>>> print(y)
{
a: False,
b: True
}
"""
return _ContainerWithGeneral._static_array_equal(
self,
Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/backends/tensorflow/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def array_equal(
/,
) -> bool:
x0, x1 = ivy.promote_types_of_inputs(x0, x1)
return bool((tf.experimental.numpy.array_equal(x0, x1)))
return bool(tf.experimental.numpy.array_equal(x0, x1))


def container_types():
Expand Down
Loading