-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Open
Labels
Description
Right now, the default arguments for sorting-related methods are:
Defaults to axis=-1:
np.sortnp.ndarray.sortnp.argsortnp.ndarray.argsortnp.ma.sortnp.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
Reactions are currently unavailable