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

Richard Orito #26712

Closed
wants to merge 2 commits into from
Closed
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
37 changes: 37 additions & 0 deletions ivy/functional/ivy/experimental/set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import ivy


def union_container(x: ivy.Container, y: ivy.Container, /) -> ivy.Container:
"""

Args:
----
x: The first container
y: The second container
------

Return:
------
A new container that contains the union of the two input containers.
"""
if isinstance(x, ivy.Array):
return ivy.union_container(x, y)
else:
return ivy.Container(set(x) | set(y))


def union_array(x: ivy.Array, y: ivy.Array, /) -> ivy.Array:
"""

Args:
----
x: The first array.
y: The second array.
------

Return:
------
A new array that contains the union of the two input arrays.
The output array has the same dtype as the input arrays.
"""
return ivy.unique_consecutive(ivy.concat((x, y), axis=0))
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ivy
import unittest


class TestUnion(unittest.TestCase):
def test_union_containers(self):
x = ivy.Container([1, 2, 3])
y = ivy.Container([4, 5, 6])
z = ivy.union_container(x, y)
self.assertEqual(z, ivy.Container([1, 2, 3, 4, 5, 6]))

def test_union_arrays(self):
x = ivy.array([1, 2, 3])
y = ivy.array([4, 5, 6])
z = ivy.union_array(x, y)
self.assertEqual(z, ivy.array([1, 2, 3, 4, 5, 6]))


if __name__ == "__main__":
unittest.main()
Binary file added libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb
Binary file not shown.
Loading