summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorhannaro <hroehling@gmx.net>2015-02-19 14:47:52 +0100
committerHanna <hanna@wlan241-190.extern.hu-berlin.de>2015-02-25 14:44:35 +0100
commit1b6f46ae7ca3361c029c480a76c737268bc8713b (patch)
tree4a88ce2104d7990cbc7b4d2e4bd9d6abdcfc1a33 /numpy/core/fromnumeric.py
parentd770034969e35907e7497d5fe9053df4bdac2fd2 (diff)
downloadnumpy-1b6f46ae7ca3361c029c480a76c737268bc8713b.tar.gz
BUG: Fixes #5524 and adds test
argpartition does not fail anymore on non-ndarray array-likes. Fix as implemented by @maniteja123.
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py10
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):