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

Improper handling of key as a tuple in dpnp_array.__getitem__() #1361

Closed
antonwolfy opened this issue Apr 3, 2023 · 0 comments · Fixed by #1362
Closed

Improper handling of key as a tuple in dpnp_array.__getitem__() #1361

antonwolfy opened this issue Apr 3, 2023 · 0 comments · Fixed by #1362
Assignees
Labels
bug Something isn't working

Comments

@antonwolfy
Copy link
Contributor

The below code caused a fault in dpnp:

# import dpnp

# x = dpnp.ones((4, 5))
# mask = dpnp.full(x.shape[1], True)
# x[:, mask]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 x[:, mask]

File /localdisk/work/antonvol/code/dpnp_dev/dpnp/dpnp/dpnp_array.py:182, in dpnp_array.__getitem__(self, key)
    179 if isinstance(key, dpnp_array):
    180     key = key.get_array()
--> 182 item = self._array_obj.__getitem__(key)
    183 if not isinstance(item, dpt.usm_ndarray):
    184     raise RuntimeError(
    185         "Expected dpctl.tensor.usm_ndarray, got {}"
    186         "".format(type(item)))

File dpctl/tensor/_usmarray.pyx:716, in dpctl.tensor._usmarray.usm_ndarray.__getitem__()

File dpctl/tensor/_slicing.pxi:171, in dpctl.tensor._usmarray._basic_slice_meta()

File dpctl/tensor/_slicing.pxi:63, in dpctl.tensor._usmarray._is_integral()

File /localdisk/work/antonvol/code/dpnp_dev/dpnp/dpnp/dpnp_array.py:217, in dpnp_array.__index__(self)
    216 def __index__(self):
--> 217     return self._array_obj.__index__()

File dpctl/tensor/_usmarray.pyx:888, in dpctl.tensor._usmarray.usm_ndarray.__index__()

IndexError: only integer arrays are valid indices

It looks dpnp wrongly handles indexing use cases when key is a tuple.

@antonwolfy antonwolfy added the bug Something isn't working label Apr 3, 2023
@antonwolfy antonwolfy self-assigned this Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant