diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2018-02-26 09:12:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 09:12:52 -0500 |
commit | 6462068ee40344ebe9a60b3ddcad0e9590d5a260 (patch) | |
tree | 8c770dc91a8b003011a81c466df5607c1c2ba56b /numpy/core/fromnumeric.py | |
parent | 8282036f0938234efab936152ad963b9ddccca83 (diff) | |
parent | 1e45ea470eaae8d23c161f78931e946847e2b7e4 (diff) | |
download | numpy-6462068ee40344ebe9a60b3ddcad0e9590d5a260.tar.gz |
Merge pull request #10658 from eric-wieser/fix-partition-matrix
BUG: Make np.partition and np.sort work on np.matrix when axis=None
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 7626b794d..de85c1143 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -657,8 +657,9 @@ def partition(a, kth, axis=-1, kind='introselect', order=None): """ if axis is None: + # flatten returns (1, N) for np.matrix, so always use the last axis a = asanyarray(a).flatten() - axis = 0 + axis = -1 else: a = asanyarray(a).copy(order="K") a.partition(kth, axis=axis, kind=kind, order=order) @@ -840,8 +841,9 @@ def sort(a, axis=-1, kind='quicksort', order=None): """ if axis is None: + # flatten returns (1, N) for np.matrix, so always use the last axis a = asanyarray(a).flatten() - axis = 0 + axis = -1 else: a = asanyarray(a).copy(order="K") a.sort(axis=axis, kind=kind, order=order) |