Skip to content

Conversation

@seberg
Copy link
Member

@seberg seberg commented Jan 7, 2026

Defer cast to input type to the end of the computation by passing through the weak_q information.

This fixes gh-30586, but I am not sure it is great to backport. Although, compared to the other PR it should just align the nan-functions fully and otherwise revert anything that isn't just a precision fix.


If we don't want to backport this, I would be tempted to just revert the original PR for 2.5, TBH.

This still needs tests, although it passes all tests added in gh-29105.

Defer cast to input type to the end of the computation by
passing through the `weak_q` information.

This fixes numpygh-30586, but I am not sure it is great to backport.
Although, compared to the other PR it should just align the nan-functions
fully and otherwise revert anything that isn't just a precision fix.
@seberg seberg requested review from eendebakpt and mhvk January 7, 2026 14:47
@seberg seberg added this to the 2.4.1 Release milestone Jan 7, 2026
@seberg
Copy link
Member Author

seberg commented Jan 7, 2026

(One tiny effect here is that previously, for arrays of longdouble, i.e. high precision, the q computation also used that higher precision. Since it now sticks to it's own default precision until the end -- we do lose that part, but I doubt there is much point in trying that hard...)

@seberg seberg added the 09 - Backport-Candidate PRs tagged should be backported label Jan 7, 2026
@seberg seberg changed the title BUG: Fix result type change and make weak q safe BUG: Undo result type change of quantile/percentile but keeping q precision Jan 8, 2026
@seberg seberg changed the title BUG: Undo result type change of quantile/percentile but keeping q precision BUG: Undo result type change of quantile/percentile but keep q precision Jan 8, 2026
@charris
Copy link
Member

charris commented Jan 9, 2026

I will put this before 2.4.1.

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. The direct test for in (int, float) make me wonder, though, if this isn't something that can be done with _array_converter? But you probably considered that, since you added that... Anyway, if that doesn't work for some reason, or is just too big an overhaul for this fixup, fine to go with this.

@charris charris merged commit b91f456 into numpy:main Jan 9, 2026
75 checks passed
@charris
Copy link
Member

charris commented Jan 9, 2026

Thanks Sebastian.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 9, 2026
charris added a commit that referenced this pull request Jan 9, 2026
BUG: Undo result type change of quantile/percentile but keep q precision (#30601)
@seberg
Copy link
Member Author

seberg commented Jan 10, 2026

Yeah, I considered it and thought it doesn't matter. _array_converter also solves the __array_wrap__ which I guess doesn't apply (at least not for this fix).
OTOH, it might still be a neat thing, just to try to remove explicit type checks...

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Return type changed in percentile for higher precision q

3 participants