diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-06-27 11:35:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 11:35:27 -0500 |
commit | 4d5b2558c275a4a46b6ab0c486536d8e779651ce (patch) | |
tree | 29da4bc4873a88541fd3f59edec03f51c2930261 /numpy/lib/function_base.py | |
parent | f156d37e63cf1f99635153e0022695285fc4a58d (diff) | |
parent | 88acbc852eeb73edd0d09c773f125725c8a0587b (diff) | |
download | numpy-4d5b2558c275a4a46b6ab0c486536d8e779651ce.tar.gz |
Merge pull request #16273 from CloseChoice/BUG-order_percentile-monotonically
BUG: Order percentile monotonically
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index cf6f4891c..1053598b1 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3879,7 +3879,13 @@ def _quantile_is_valid(q): def _lerp(a, b, t, out=None): """ Linearly interpolate from a to b by a factor of t """ - return add(a*(1 - t), b*t, out=out) + diff_b_a = subtract(b, a) + # asanyarray is a stop-gap until gh-13105 + lerp_interpolation = asanyarray(add(a, diff_b_a*t, out=out)) + subtract(b, diff_b_a * (1 - t), out=lerp_interpolation, where=t>=0.5) + if lerp_interpolation.ndim == 0 and out is None: + lerp_interpolation = lerp_interpolation[()] # unpack 0d arrays + return lerp_interpolation def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False, |