| 797 | low_high = np.take_along_axis(asorted, lh, axis=axis) |
| 798 | |
| 799 | def replace_masked(s): |
| 800 | # Replace masked entries with minimum_full_value unless it all values |
| 801 | # are masked. This is required as the sort order of values equal or |
| 802 | # larger than the fill value is undefined and a valid value placed |
| 803 | # elsewhere, e.g. [4, --, inf]. |
| 804 | if np.ma.is_masked(s): |
| 805 | rep = (~np.all(asorted.mask, axis=axis, keepdims=True)) & s.mask |
| 806 | s.data[rep] = np.ma.minimum_fill_value(asorted) |
| 807 | s.mask[rep] = False |
| 808 | |
| 809 | replace_masked(low_high) |
| 810 | |