Skip to content

Commit

Permalink
add unique
Browse files Browse the repository at this point in the history
  • Loading branch information
bilal-aamer committed Aug 14, 2023
1 parent dd963e2 commit 8436a18
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ivy/data_classes/array/experimental/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,20 @@ def associative_scan(
"""
return ivy.associative_scan(self._data, fn, reverse=reverse, axis=axis)

def unique(
self: ivy.Array,
/,
*,
axis: Optional[int] = None,
) -> Tuple[ivy.Array, ivy.Array]:
"""
ivy.Array instance method variant of ivy.unique.
This method simply wraps the function, and so the docstring for
ivy.unique also applies to this method with minimal changes.
"""
return ivy.unique(self._data, axis=axis)

def unique_consecutive(
self: ivy.Array,
/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,36 @@ def test_associative_scan(
)


# unique
@handle_test(
fn_tree="unique",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("numeric"),
min_num_dims=1,
min_dim_size=2,
force_int_axis=True,
valid_axis=True,
),
none_axis=st.booleans(),
test_with_out=st.just(False),
test_gradients=st.just(False),
ground_truth_backend="torch",
)
def test_unique(*, dtype_x_axis, none_axis, test_flags, backend_fw, fn_name, on_device):
dtype, x, axis = dtype_x_axis
if none_axis:
axis = None
helpers.test_function(
input_dtypes=dtype,
test_flags=test_flags,
backend_to_test=backend_fw,
fn_name=fn_name,
on_device=on_device,
x=x,
axis=axis,
)


# unique_consecutive
@handle_test(
fn_tree="unique_consecutive",
Expand Down

0 comments on commit 8436a18

Please sign in to comment.