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

ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__ #8072

Closed
wants to merge 2 commits into from

Conversation

xhochy
Copy link
Member

@xhochy xhochy commented Aug 28, 2020

FYI @marc9595

@github-actions
Copy link

Comment on lines 161 to 164
elif isinstance(key, int):
return self.getitem(key)
elif np.isscalar(key) and np.issubdtype(key.dtype, np.integer):
return self.getitem(key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative is to do like array.pxi, and let python/cython handle the cast to integer (and let it raise error otherwise:

Suggested change
elif isinstance(key, int):
return self.getitem(key)
elif np.isscalar(key) and np.issubdtype(key.dtype, np.integer):
return self.getitem(key)
return self.getitem(_normalize_index(key, self.chunked_array.length()))

(minor downside is that the error message will only speak about "integer", and not "slice", but then anything convertible to int will be accepted automatically)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should probably use the same solution everywhere (and possibly avoid manual handling of Numpy scalars).

@jorisvandenbossche
Copy link
Member

@xhochy do you have time to update this?

@xhochy
Copy link
Member Author

xhochy commented Sep 30, 2020

Maybe Friday or Monday

Copy link
Member

@kszucs kszucs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging on green.

@kszucs kszucs closed this in d908bc8 Oct 9, 2020
@xhochy xhochy deleted the ARROW-9879 branch November 26, 2020 13:01
GeorgeAp pushed a commit to sirensolutions/arrow that referenced this pull request Jun 7, 2021
…getitem__

FYI @marc9595

Closes apache#8072 from xhochy/ARROW-9879

Lead-authored-by: Uwe L. Korn <uwelk@xhochy.com>
Co-authored-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
Signed-off-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants