Skip to content

Commit

Permalink
BUG: Allow any array-like input to percentile.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed May 16, 2010
1 parent 44b42db commit 7c92f32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions numpy/lib/function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 7c92f32

Please sign in to comment.