-
Notifications
You must be signed in to change notification settings - Fork 9
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
BUG: fix tuple array indexing #139
Conversation
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.
Looks like a great start!
Now that we're at it, could you add some more checks:
For a.device == idx.device
:
a[idx, 1].device == a.device
a[idx, ...].device == a.device
- other legal ways of indexing preserve the device
. - there's an error when indexing and indexed arrays are on different devices.
Good call, different devices were allowed. I've fixed but not 100% on wording of error message, happy to change. |
np_key = key._array if isinstance(key, Array) else key | ||
if isinstance(key, Array): | ||
key = (key,) | ||
np_key = key |
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.
The new naming key
-> np_key
, meant that I've had to add this line
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.
LGTM, thank you @lucyleeow !
CI is green after the rerun, including just-added python 3.13 jobs. Thanks @lucyleeow , keep them coming! |
closes #134
When indexing with tuple containing
Array
s, convert to numpy array (self._array
) first. Not doing so results in e.g. "Can not convert array on the 'array_api_strict.Device('device1')' device to a Numpy array." errorParametrized indexing tests for all devices. Also added shape checks in test because while working on this PR, I created a bug that was not picked up by the test in the current format as the bug also affected the loop arrays.
cc @ev-br