-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: non-unique, masked dtype index raising IndexError #57061
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
REGR: non-unique, masked dtype index raising IndexError #57061
Conversation
pandas/_libs/index.pyx
Outdated
@@ -1220,6 +1220,7 @@ cdef class MaskedIndexEngine(IndexEngine): | |||
n_alloc *= 2 | |||
if n_alloc > max_alloc: | |||
n_alloc = max_alloc | |||
result = np.resize(result, n_alloc) |
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 this required to resize here? If so can we get rid of the resize that happens after this branch is completed? Might be misreading but it looks duplicative
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.
I think this is required. The result size isn't known so I believe the resize check needs to be done each time a new value is set. I don't see a way to avoid it with the current algo.
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.
Ah yea that makes sense. I think its worth making the conditional resize its own function then so we don't have as much duplication
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.
good idea - done
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.
Looking pretty good
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.
Just a merge conflict otherwise looks good
Thanks @lukemanley |
…ising IndexError
…dex raising IndexError) (#57142) Backport PR #57061: REGR: non-unique, masked dtype index raising IndexError Co-authored-by: Luke Manley <[email protected]>
…7061) * fix masked indexing regression * fix test * fix test * dedup resizing logic * add types
doc/source/whatsnew/v2.2.1.rst
file if fixing a bug or adding a new feature.