Repository navigation
Fix negative indices in rolling argmin/argmax at array edges - #11900
Open
ptlnextdoor wants to merge 1 commit into
Open
ptlnextdoor wants to merge 1 commit into
ptlnextdoor wants to merge 1 commit into
Conversation
When a real value equals the padding sentinel (True, inf, or the largest integer for argmin), the reduction picks the padding. Subtracting the padding count then gave a negative index. Clip the index at 0, the first value of the window inside the array. Co-authored-by: Claude <noreply@anthropic.com>
|
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Rolling and cumulative
argmin/argmaxreturned negative indices at the array edges when a value equals the padding sentinel. This is a regression from #11696 and is onmainonly.Edge windows are padded with
True(bool),inf(float) or the largest integer. #11696 subtracts the pad count from the index. If a real value ties with the sentinel,argminpicks the padding and the index goes negative. Example:The result is now
[0, 0, 2, 1], asnp.argmingives on each window. The fix clips the index at 0, the first value of the window inside the array. If the padding wins, all real values in the window tie with it, so 0 is correct.This PR fixes only item 1 of the issue. The groupby items (2, 3) and the bottleneck tie difference (4) have different causes and are not changed.
Tests: new
test_rolling_argminmax_ties_with_padding(bool, float and int64 cases; rolling and cumulative; numbagg on and off). It fails onmainand passes now. The wholexarray/tests/test_rolling.pypasses (3675 passed, 34 skipped).ruff checkandruff formatare clean on the changed files. I did not run the full test suite.Checklist
Fixes #11899
whats-new.rstapi.rstAI Disclosure
Tools: Claude (Anthropic)
AI disclosure: this PR was prepared with AI assistance (Claude, Anthropic).