Skip to content

BUG: Allow np.percentile to operate on float16 data #29105

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

eendebakpt
Copy link
Contributor

@eendebakpt eendebakpt commented May 31, 2025

Fixes #29003

The approach taken to address the issue is to perform index calculations with increased precision, but keep the behaviour that for arr of dtype float16 the output np.quantile(arr, q) is of the same type.

The behaviour to have the same output type makes sense for float input, but cannot hold for integer input. E.g. we want np.quantile([1, 2], 0.5, method='linear') to output 1.5. For that reason it might also be ok to just upcase the type to float64.

There are also some corner cases. For example input (of either the array or the quantile) of type Fraction. Possible output types could be either Fraction or float64.

@eendebakpt eendebakpt force-pushed the percentile_float16 branch from 2f15050 to 74a93b4 Compare May 31, 2025 22:46
@eendebakpt eendebakpt force-pushed the percentile_float16 branch from 74a93b4 to 6766c8d Compare June 1, 2025 18:06
@eendebakpt eendebakpt changed the title Draft: BUG: Allow np.percentile to operate on float16 data BUG: Allow np.percentile to operate on float16 data Jun 1, 2025
@charris
Copy link
Member

charris commented Jun 3, 2025

Could use a release note.

@eendebakpt
Copy link
Contributor Author

Could use a release note.

I agree. Not sure how to phrase it though, suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: np.percentile fails with internal overflow when using float16 input on large arrays
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy