Open
Description
A masked array containing nan
currently sorts such that nan
s appear at the end of the array, violating endwith=True
:
>>> m = np.ma.masked_array([np.nan, -1], mask=[0, 1])
>>> m
masked_array(data = [nan --],
mask = [False True],
fill_value = 1e+20)
>>> m.sort()
>>> m
masked_array(data = [-- nan],
mask = [ True False],
fill_value = 1e+20)
Apart from its own contract, this breaks consistency within the current implementation of np.ma.median
(which should probably not rely on sort
anyway), returning:
>>> np.ma.median(np.ma.masked_array([np.nan, 5, -1], mask=[0, 0, 1]))
5.0
>>> np.ma.median(np.ma.masked_array([np.nan, 5], mask=[0, 0]))
nan
(not that I'm sure what it means to take a median when there are nan
s present)
Perhaps minimum_fill_value
needs an alternative for the sort
case because of the convention that nan
comes last.