summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-11-08 16:37:41 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2021-11-12 12:12:00 -0600
commit85f3ddab60e522968dd6222a92a19a81eda036a8 (patch)
treed3aeb04090865a1f5f4e7d0e9cd6031bde6fc88f /numpy/lib/function_base.py
parent3993408877ab414cb5e3639ac0e20fdec972933f (diff)
downloadnumpy-85f3ddab60e522968dd6222a92a19a81eda036a8.tar.gz
BUG: quantile discrete methods ended up using -1 as index sometimes
Also, the closest-observation did not correctly support multiple quantiles calculated at the same time (broadcasting error).
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index cef281fab..dee64c671 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4487,7 +4487,7 @@ def _lerp(a, b, t, out=None):
def _get_gamma_mask(shape, default_value, conditioned_value, where):
out = np.full(shape, default_value)
- out[where] = conditioned_value
+ np.copyto(out, conditioned_value, where=where, casting="unsafe")
return out
@@ -4495,11 +4495,14 @@ def _discret_interpolation_to_boundaries(index, gamma_condition_fun):
previous = np.floor(index)
next = previous + 1
gamma = index - previous
- return _get_gamma_mask(shape=index.shape,
- default_value=next,
- conditioned_value=previous,
- where=gamma_condition_fun(gamma, index)
- ).astype(np.intp)
+ res = _get_gamma_mask(shape=index.shape,
+ default_value=next,
+ conditioned_value=previous,
+ where=gamma_condition_fun(gamma, index)
+ ).astype(np.intp)
+ # Some methods can lead to out-of-bound integers, clip them:
+ res[res < 0] = 0
+ return res
def _closest_observation(n, quantiles):