10000 API: Change default axis argument for argsort. by eric-wieser · Pull Request #8904 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: Change default axis argument for argsort. #8904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/release/1.13.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Dropped Support
Deprecations
============

* ``np.ma.argsort`` should be called with an explicit `axis` argument when
applied to arrays with more than 2 dimensions, as the default value of
this argument (``None``) is inconsistent with the rest of numpy (``-1``).


Build System Changes
====================
Expand Down
4 changes: 2 additions & 2 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5228,7 +5228,7 @@ def round(self, decimals=0, out=None):
out.__setmask__(self._mask)
return out

def argsort(self, axis=None, kind='quicksort', order=None,
def argsort(self, axis=-1, kind='quicksort', order=None,
endwith=True, fill_value=None):
"""
Return an ndarray of indices that sort the array along the
Expand Down Expand Up @@ -6503,7 +6503,7 @@ def power(a, b, third=None):
argmin = _frommethod('argmin')
argmax = _frommethod('argmax')

def argsort(a, axis=None, kind='quicksort', order=None, endwith=True, fill_value=None):
def argsort(a, axis=-1, kind='quicksort', order=None, endwith=True, fill_value=None):
"Function version of the eponymous method."
a = np.asanyarray(a)

Expand Down
12 changes: 12 additions & 0 deletions numpy/ma/tests/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Test deprecation and future warnings.

"""
from __future__ import division, absolute_import, print_function

import numpy as np
from numpy.testing import TestCase, run_module_suite, assert_warns
from numpy.ma.testutils import assert_equal


if __name__ == "__main__":
run_module_suite()
0