-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add implementation of dpnp.unique
#1972
Conversation
View rendered docs @ https://intelpython.github.io/dpnp/index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When axis is given NumPy
list all rows with NaN
at the bottom while dpnp
does not.
import dpnp, numpy
import numpy as np
a = numpy.array([[1, 0, 0], [1, 0, 0], [np.nan, np.nan, np.nan], [2, 3, 4], [1, 0, 1], [np.nan, np.nan, np.nan]])
numpy.unique(a, axis=0)
# array([[ 1., 0., 0.],
# [ 1., 0., 1.],
# [ 2., 3., 4.],
# [nan, nan, nan],
# [nan, nan, nan]])
dpnp.unique(dpnp.asarray(a), axis=0)
#array([[ 1., 0., 0.],
# [nan, nan, nan],
# [ 1., 0., 1.],
# [ 2., 3., 4.],
# [nan, nan, nan]])
In addition equal_nan=True
is not working as expected when axis
is given for both NumPy
and dpnp
. Is it the way it should be?
import dpnp, numpy
import numpy as np
a = numpy.array([[1, 0, 0], [1, 0, 0], [np.nan, np.nan, np.nan], [2, 3, 4], [1, 0, 1], [np.nan, np.nan, np.nan]])
numpy.unique(a, axis=0, equal_nan=True)
# array([[ 1., 0., 0.],
# [ 1., 0., 1.],
# [ 2., 3., 4.],
# [nan, nan, nan],
# [nan, nan, nan]])
dpnp.unique(dpnp.asarray(a), axis=0, equal_nan=True)
#array([[ 1., 0., 0.],
# [nan, nan, nan],
# [ 1., 0., 1.],
# [ 2., 3., 4.],
# [nan, nan, nan]])
Thank you for noticing that. |
The PR adds implementation of
dpnp.unique
function.The implementation leverages on dpctl.tensor implementation when axis is None. Otherwise it is implemented through python calls. The functionality is covered by new tests and enabled third party tests.