diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2010-05-16 08:30:47 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2010-05-16 08:30:47 +0000 |
commit | 7c92f3237ec81e42d490d3b5eff89725608a112d (patch) | |
tree | 37487019014bab22d9935e81db395be450d0ea13 /numpy | |
parent | 44b42db55290aedbf3e30ef2de81d0bccc547a04 (diff) | |
download | numpy-7c92f3237ec81e42d490d3b5eff89725608a112d.tar.gz |
BUG: Allow any array-like input to percentile.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b42452b4a..7d825136c 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2940,6 +2940,8 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False): >>> assert not np.all(a==b) """ + a = np.asarray(a) + if q == 0: return a.min(axis=axis, out=out) elif q == 100: diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 10e3790ea..4949eba5d 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -967,5 +967,8 @@ def compare_results(res, desired): assert_array_equal(res[i], desired[i]) +def test_percentile_list(): + assert_equal(np.percentile([1,2,3], 0), 1) + if __name__ == "__main__": run_module_suite() |