-
Notifications
You must be signed in to change notification settings - Fork 23
Implement dpnp.isin
#2595
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
base: master
Are you sure you want to change the base?
Implement dpnp.isin
#2595
Conversation
de4e3bb to
df81181
Compare
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/2595/index.html |
|
Array API standard conformance tests for dpnp=0.20.0dev1=py313h509198e_7 ran successfully. |
dpnp/dpnp_iface_logic.py
Outdated
| return a.flags.fnc | ||
|
|
||
|
|
||
| def isin(element, test_elements, assume_unique=False, invert=False): |
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.
NumPy supports also kind keyword, but we can limit it with only None and 'sort' values and state a limitation that 'table' is not supported
| def isin(element, test_elements, assume_unique=False, invert=False): | |
| def isin(element, test_elements, assume_unique=False, invert=False, *, kind=None): |
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.
CuPy ignores this keyword though, which is why I chose to. I can add it in if you'd like, to be ignored like assume_unique
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.
Yep, it'd be good to add.
df81181 to
0b51fa3
Compare
07f280b to
7d29652
Compare
7d29652 to
42e9893
Compare
| input arrays are unique. Included for compatibility with NumPy. | ||
| Default: ``False``. |
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.
We need to have an empty line before Default: .. to have it always from the new line in the rendered documentation:
| input arrays are unique. Included for compatibility with NumPy. | |
| Default: ``False``. | |
| input arrays are unique. Included for compatibility with NumPy. | |
| Default: ``False``. |
| Default: ``False``. | ||
| invert : bool, optional | ||
| If ``True``, the values in the returned array are inverted, as if | ||
| calculating `element not in test_elements`. |
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.
To align with the form used at the top of the function description:
| calculating `element not in test_elements`. | |
| calculating ``element not in test_elements``. |
| than) ``dpnp.invert(dpnp.isin(a, b))``. | ||
| Default: ``False``. |
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.
an empty line is missing:
| than) ``dpnp.invert(dpnp.isin(a, b))``. | |
| Default: ``False``. | |
| than) ``dpnp.invert(dpnp.isin(a, b))``. | |
| Default: ``False``. |
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.
excess empty line:
|
|
||
| dpnp.check_supported_arrays_type(element, test_elements, scalar_type=True) | ||
| usm_element = dpnp.as_usm_ndarray( | ||
| element, usm_type=element.usm_type, sycl_queue=element.sycl_queue |
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.
element might be a scalar, but in that case test_elements is not scalar:
| element, usm_type=element.usm_type, sycl_queue=element.sycl_queue | |
| element, usm_type=test_elements.usm_type, sycl_queue=test_elements.sycl_queue |
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.
Or, alternatively, we need to calculate common SYCL queue and USM type somewhere above and pass here and to as_usm_ndarray below
| assert_equal(result, expected) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("dtype", get_all_dtypes()) |
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.
| @pytest.mark.parametrize("dtype", get_all_dtypes()) | |
| @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) |
| assert_equal(result, expected) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( |
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.
It'd be great to have new tests placed inside a class TestIsin
| assert_equal(result, expected) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( |
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.
CFD tests are missing, need to add one to test_sycl_queue.py and another to test_usm_type.py
This PR leverages the recently-added
dpctl.tensor.isinto implementdpnp.isin