Uh oh!
There was an error while loading. Please reload this page.
Replace int with SupportsIndex in indexing methods hints - #766
Conversation
753697f to
8ccd67dCompare8ccd67d to
3c9c047CompareUh oh!
There was an error while loading. Please reload this page.
rgommers
commented
Mar 21, 2024
Thanks @honno. Adding a quick clarifying example: >>>importnumpyasnp>>>importtorch>>>>>>x=np.arange(1, 4)
>>>y=torch.arange(1, 4)
>>>>>>classIx:
... def__index__(self):
... return1
... >>>x[Ix()]
2>>>y[Ix()]
tensor(2) |
Uh oh!
There was an error while loading. Please reload this page.
0c9c42d to
18910c0CompareMight fix rendering/warning issue
rgommers
commented
Mar 25, 2024
@honno would you be able to open a PR with a test for this to |
| .. note:: | ||
| ``key`` can only be an array if it is valid for boolean array indexing, or supports ``__index__()``. |
There was a problem hiding this comment.
Presumably somewhere else we say it should support __index__ if and only if it is a 0-D integer array. Maybe it would be clearer to just say that directly here.
There was a problem hiding this comment.
Yep that'd help, let me know on the wording from my latest commit.
Good shout, I opened data-apis/array-api-tests#247 to check this all out. From the looks of it:
|
asmeurer
commented
Mar 27, 2024
Let me know what you find out. We do run it on CI with some skips and xfails, and also the max-examples is set to 5. I haven't looked at the Dask xfails too closely, and obviously if we can remove any of those that would be great. CC @lithomas1 |
kgryte
commented
Apr 18, 2024
@honno Were you able to triage the Dask issues with the test suite? |
honno
commented
Apr 22, 2024
Got Dask working1—the latest release at least doesn't support indexables for both get and set items right now ( Footnotes
|
asmeurer
commented
Apr 22, 2024
By the way, for implementers, the generally correct behavior is to |
kgryte
commented
Sep 19, 2024
@honno Is there anything more that we need to do with this PR? |
PR I think I'm happy with, just be mindful that last I checked in March it was only NumPy and PyTorch that supported "indexables", whereas JAX/CuPy/Dask didn't, so they'd need updating to support this. Example of what I mean by an indexable: classAwkwardIndexable:
def__init__(self, value: int):
self._value=valuedef__int__(self):
raiseTypeError("__int__() should not be called")
def__index__(self):
returnself._value |
Resolves#383