diff options
author | czgdp1807 <gdp.1807@gmail.com> | 2021-09-03 12:17:26 +0530 |
---|---|---|
committer | czgdp1807 <gdp.1807@gmail.com> | 2021-09-03 12:17:26 +0530 |
commit | 781d0a7ac61ce007e65abcd4e30f2181e729ae61 (patch) | |
tree | f45f38a246bcefbca9ca8a08bd8ba55cbc6cdb15 /numpy/array_api/_set_functions.py | |
parent | b341e4c3249817d2e14ddf71aa850a8a896b9303 (diff) | |
parent | 2ae1e068710174dc57b5ba5ad688517608efcf26 (diff) | |
download | numpy-781d0a7ac61ce007e65abcd4e30f2181e729ae61.tar.gz |
resolved conflicts
Diffstat (limited to 'numpy/array_api/_set_functions.py')
-rw-r--r-- | numpy/array_api/_set_functions.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/numpy/array_api/_set_functions.py b/numpy/array_api/_set_functions.py new file mode 100644 index 000000000..357f238f5 --- /dev/null +++ b/numpy/array_api/_set_functions.py @@ -0,0 +1,31 @@ +from __future__ import annotations + +from ._array_object import Array + +from typing import Tuple, Union + +import numpy as np + + +def unique( + x: Array, + /, + *, + return_counts: bool = False, + return_index: bool = False, + return_inverse: bool = False, +) -> Union[Array, Tuple[Array, ...]]: + """ + Array API compatible wrapper for :py:func:`np.unique <numpy.unique>`. + + See its docstring for more information. + """ + res = np.unique( + x._array, + return_counts=return_counts, + return_index=return_index, + return_inverse=return_inverse, + ) + if isinstance(res, tuple): + return tuple(Array._new(i) for i in res) + return Array._new(res) |