summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-02-23 14:41:51 +0000
committerEric Wieser <wieser.eric@gmail.com>2017-03-07 16:09:43 +0000
commitf91eb364283bf6066f3a18e4b9738bc3452d155b (patch)
tree5aeb1a123b8e43b596b4455af31d17e6ce88d8c5
parent9c865d565e10fa7461560fa3d99eadaa4feebcad (diff)
downloadnumpy-f91eb364283bf6066f3a18e4b9738bc3452d155b.tar.gz
MAINT: Combine ma.argsort and MaskedArray.argsort
-rw-r--r--numpy/ma/core.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 3c26a45e5..427c146a2 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -6500,20 +6500,19 @@ def power(a, b, third=None):
result._data[invalid] = result.fill_value
return result
+argmin = _frommethod('argmin')
+argmax = _frommethod('argmax')
def argsort(a, axis=None, kind='quicksort', order=None, fill_value=None):
"Function version of the eponymous method."
- if fill_value is None:
- fill_value = default_fill_value(a)
- d = filled(a, fill_value)
- if axis is None:
- return d.argsort(kind=kind, order=order)
- return d.argsort(axis, kind=kind, order=order)
-argsort.__doc__ = MaskedArray.argsort.__doc__
-
-argmin = _frommethod('argmin')
-argmax = _frommethod('argmax')
+ a = np.asanyarray(a)
+ if isinstance(a, MaskedArray):
+ return a.argsort(axis=axis, kind=kind, order=order,
+ fill_value=fill_value)
+ else:
+ return a.argsort(axis=axis, kind=kind, order=order)
+argsort.__doc__ = MaskedArray.argsort.__doc__
def sort(a, axis=-1, kind='quicksort', order=None, endwith=True, fill_value=None):
"Function version of the eponymous method."