10000 BUG: np.ma.argsort has different default for axis than ndarray · Issue #8701 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: np.ma.argsort has different default for axis than ndarray #8701

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

Open
eric-wieser opened this issue Feb 26, 2017 · 0 comments
Open

BUG: np.ma.argsort has different default for axis than ndarray #8701

eric-wieser opened this issue Feb 26, 2017 · 0 comments

Comments

@eric-wieser
Copy link
Member
eric-wieser commented Feb 26, 2017

Right now, the default arguments for sorting-related methods are:

Defaults to axis=-1:

  • np.sort
  • np.ndarray.sort
  • np.argsort
  • np.ndarray.argsort
  • np.ma.sort
  • np.masked_array.sort
  • The documentation of np.ma.argsort
  • The documentation of np.masked_array.argsort

Defaults to axis=None:

  • The implementation of np.ma.argsort
  • The implementation of np.masked_array.argsort

For 1D arrays, there is no difference, as None just means flatten and use the only axis.

For 2D arrays, however, code written for ndarrays can fail in unexpected ways when passed a masked_array, because argsort breaks liskov subsitution:

def foo(x):
    i = x.argsort()
    assert(i.shape == x.shape)

>>> foo(som_arr)  # ok
>>> foo(som_arr.view(MaskedArray)) # AssertionError
eric-wieser added a commit to eric-wieser/numpy that referenced this issue Apr 10, 2017
Only deprecated when this would be ambiguous.

Approaches numpy#8701
eric-wieser added a commit to eric-wieser/numpy that referenced this issue Apr 11, 2017
Now matches:
 * its own documentation
 * everything else

Fixes numpy#8701
eric-wieser added a commit to eric-wieser/numpy that referenced this issue May 5, 2017
Only deprecated when this would be ambiguous.

Approaches numpy#8701
mherkazandjian pushed a commit to mherkazandjian/numpy that referenced this issue May 30, 2017
Only deprecated when this would be ambiguous.

Approaches numpy#8701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0