8000 BUG ensure monotonic property of lerp in numpy.percentile by glemaitre · Pull Request #15098 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG ensure monotonic property of lerp in numpy.percentile #15098

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

Closed
wants to merge 15 commits into from
Closed
Prev Previous commit
Next Next commit
avoid intermediate copy
  • Loading branch information
glemaitre committed Dec 23, 2019
commit 64c6fa15f61abb61fa3378d6bb2af920ade0d7cf
7 changes: 3 additions & 4 deletions numpy/lib/function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3898,7 +3898,6 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
indices = indices[0]
r = take(ap, indices, axis=axis, out=out)


else: # weight the points above and below the indices
indices_below = floor(indices).astype(intp)
indices_above = indices_below + 1
Expand Down Expand Up @@ -3949,15 +3948,15 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
r_above = r_above.squeeze(0)
r_below = r_below.squeeze(0)

r = np.where(weights_above < 0.5, r_above, r_below)
r_above[r_above < 0.5] = r_below

if out is not None:
out[...] = r
out[...] = r_above
r = out
Copy link
Member

Choose a reason for hiding this comment

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

Assignment to out should not be necessary here, the above operation is already in-place (i.e. similar to the old branch, which did not do this).

Copy link
Member

Choose a reason for hiding this comment

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

@seberg is the double-assignment cleanup a blocker?

Copy link
Member

Choose a reason for hiding this comment

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

Not on its own, but I think the above also needs some cleanups, maybe I should just put it on my todo list to do it myself.

else:
# get the element stored in the 0-d array for backward
# compatibility
r = r[()]
r = r_above[()]

if np.any(n):
if zerod:
Expand Down
0