Repository navigation
GH-55769: [C++][Python] Preserve leading NaNs in cumulative min and max - #55822
Closed
karthiksenv wants to merge 1 commit into
Closed
karthiksenv wants to merge 1 commit into
karthiksenv wants to merge 1 commit into
Conversation
karthiksenv
marked this pull request as ready for review
November 27, 2026 22:45
Member
|
Closing this PR as it doesn't meet our guidelines on AI-generated contributions: https://arrow.apache.org/docs/developers/overview.html#ai-generated-code If you'd like to contribute this change, please review and test the code yourself, then open a new PR. |
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.
Rationale for this change
With the default start,
cumulative_max([NaN])returns negative infinity andcumulative_min([NaN])returns positive infinity. The corresponding aggregates return NaN.What changes are included in this PR?
Use quiet NaN as the floating-point identity for min and max. The existing operators select the numeric operand when only one operand is NaN, so the first number establishes the running extremum. Update the function docs and point
cumulative_meanat its own docstring so it does not inherit the maximum's NaN behavior in its documentation.Are these changes tested?
Reproduced the bug with the PyArrow 25.0.1 and 26.0.1 wheels on macOS 15.8.2 arm64 with Python 3.12.10. On the patched source build, all 1,157 C++ vector tests passed. The reported Python examples passed for float32 and float64, as did checks for chunk boundaries, null handling, and explicit starts. Validation run
Are there any user-facing changes?
With the default start, a leading run of NaNs now produces NaNs. For example,
cumulative_max([NaN, 1, NaN, 2])returns[NaN, 1, 1, 2]. An explicit numeric start participates from the first element.This PR contains a "Critical Fix". The previous default could introduce an infinity into a result even when the input contained only NaNs.
Was AI used for this PR?
AI wrote and reviewed the patch, tests, and description.
Closes #55769.