-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
API: ensure IntervalIndex.left/right are 64bit if numeric #50130
Conversation
a009f43
to
7e1fbdf
Compare
7e1fbdf
to
5835d00
Compare
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.
Is there a use-case for non 64-bit arrays?
pandas/core/indexes/interval.py
Outdated
def _maybe_convert_numeric_to_64bit(self, idx: Index) -> Index: | ||
# IntervalTree only supports 64 bit numpy array | ||
dtype = idx.dtype | ||
if np.issubclass_(idx.dtype.type, np.number): |
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.
can you use dtype.type here?
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.
Yes:)
Not for me personally, it was more of a question I had when I wrote the code, and we now will support non-64-bit indexes. IMO this can come later, if someone sees a need for it. |
Sounds good to me. What we have to keep in mind a bit: If we compile IntervalTree for all possible dtypes, this will further increase the size of pandas for end users. So as long as there is no use case, I would keep as is. But open to revisit if there is a situation where this would be helpful |
Yeah, I agree. I’ve updated the PR. |
Thx @topper-123 |
Extracted part for #49560, slightly altered.
IntervalIndex
depends onIntervalTree
which only accepts 64-bit int/uint/floats. This ensures that numpy numeric arrays inIntervalTree
will always be 64-bit.A question is if we should have non-64bit
IntervalTree
s. I've considered that that is maybe a different question than #49650, and I could write an issue about it and someone could take it in a follow-up, possibly before 2.0?This PR changes nothing functionality-wise, but is needed when
Index
can have non-64bit indexes after #49650.