diff options
author | Jaime <jaime.frio@gmail.com> | 2015-02-25 07:09:39 -0800 |
---|---|---|
committer | Jaime <jaime.frio@gmail.com> | 2015-02-25 07:09:39 -0800 |
commit | 5e9750dee0d861342c2fe184b755454d7215f10a (patch) | |
tree | df29563ad12467c7ccd04b3e5ccb1d2d24717ee7 /numpy/core/fromnumeric.py | |
parent | 2e016ac65aceab4e08217794d6be7b365793976a (diff) | |
parent | 1b6f46ae7ca3361c029c480a76c737268bc8713b (diff) | |
download | numpy-5e9750dee0d861342c2fe184b755454d7215f10a.tar.gz |
Merge pull request #5584 from hannaro/bugfix_argpartition
BUG: Fixed issue #5524 and added test
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index aef09411a..c518309a0 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -691,8 +691,16 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None): >>> x[np.argpartition(x, (1, 3))] array([1, 2, 3, 4]) + >>> x = [3, 4, 2, 1] + >>> np.array(x)[np.argpartition(x, 3)] + array([2, 1, 3, 4]) + """ - return a.argpartition(kth, axis, kind=kind, order=order) + try: + argpartition = a.argpartition + except AttributeError: + return _wrapit(a, 'argpartition',kth, axis, kind, order) + return argpartition(kth, axis, kind=kind, order=order) def sort(a, axis=-1, kind='quicksort', order=None): |