| 815 | low_high = np.take_along_axis(asorted, lh, axis=axis) |
| 816 | |
| 817 | def replace_masked(s): |
| 818 | # Replace masked entries with minimum_full_value unless it all values |
| 819 | # are masked. This is required as the sort order of values equal or |
| 820 | # larger than the fill value is undefined and a valid value placed |
| 821 | # elsewhere, e.g. [4, --, inf]. |
| 822 | if np.ma.is_masked(s): |
| 823 | rep = (~np.all(asorted.mask, axis=axis, keepdims=True)) & s.mask |
| 824 | s.data[rep] = np.ma.minimum_fill_value(asorted) |
| 825 | s.mask[rep] = False |
| 826 | |
| 827 | replace_masked(low_high) |
| 828 | |