summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-04-25 22:46:53 -0700
committerGitHub <noreply@github.com>2019-04-25 22:46:53 -0700
commitc37befb43ae9477a5e0ff1faeb5aa493a135805b (patch)
treee1bfcaaa0a203e372253c402494a1b7753d1d6ce /numpy/lib/function_base.py
parent9218e593d05c1231a8b2c72d47967e02099070ae (diff)
parent9a23f16b67958205468f7f5c4e0966f393558d9a (diff)
downloadnumpy-c37befb43ae9477a5e0ff1faeb5aa493a135805b.tar.gz
Merge pull request #13390 from eric-wieser/quantile-fraction
ENH: Add support for Fraction to percentile and quantile
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 2e82fa075..cab680751 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -3706,7 +3706,8 @@ def percentile(a, q, axis=None, out=None,
plt.show()
"""
- q = np.true_divide(q, 100.0) # handles the asarray for us too
+ q = np.true_divide(q, 100)
+ q = asanyarray(q) # undo any decay that the ufunc performed (see gh-13105)
if not _quantile_is_valid(q):
raise ValueError("Percentiles must be in the range [0, 100]")
return _quantile_unchecked(
@@ -3924,7 +3925,7 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
indices_above = concatenate((indices_above, [-1]))
weights_above = indices - indices_below
- weights_below = 1.0 - weights_above
+ weights_below = 1 - weights_above
weights_shape = [1, ] * ap.ndim
weights_shape[axis] = len(indices)