BUG: nanquantile dtype depends on first slice NaN pattern - #32833
Open
charan-rathore wants to merge 1 commit into
Open
charan-rathore wants to merge 1 commit into
charan-rathore wants to merge 1 commit into
Conversation
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.
PR summary
Closes #32832.
nanquantile/nanpercentile(and the other nan-functions sharing the_nanquantile_ureduce_funcpath) returned a dtype that depended on whether the FIRST slice happened to be all-NaN: an all-NaN first slice silently flipped the result between float32 and float64 relative to an identical call whose first slice contained data. The result dtype should not depend on the NaN pattern of the first slice. This fixes the dtype selection so it is consistent regardless of which slices are all-NaN, and adds regression coverage across float16/32/64, 13 method variants, and several q shapes.First time contributor introduction
First-time NumPy contributor. I found this bug through issue triage and reproduced it directly from the report in #32832 before preparing the fix.
AI Disclosure
AI assistance (Instinct assisted) was used in the preparation of this PR: the fix and regression tests were drafted with AI assistance under my direction, and I directed and approved the submission. The test runs were executed on a CPU runner in the assistant's environment: the checkout's pure-Python
numpy/lib/_nanfunctions_impl.pyloaded atop an installed NumPy 2.5.3 compiled runtime (no fresh from-source build; the runner bypasses one compiled-API import that is irrelevant to this module). Fulltest_nanfunctions.py: 1319 passed, 86 skipped with the patch; the 32 new regression cases fail without it (red-green verified).Additional context