Adjust the axis passed to argsort, warning if necessary Parameters ---------- arr The array which argsort was called on np.ma.argsort has a long-term bug where the default of the axis argument is wrong (gh-8701), which now must be kept for backwards compatibility.
(arr)
| 85 | pass |
| 86 | |
| 87 | def _deprecate_argsort_axis(arr): |
| 88 | """ |
| 89 | Adjust the axis passed to argsort, warning if necessary |
| 90 | |
| 91 | Parameters |
| 92 | ---------- |
| 93 | arr |
| 94 | The array which argsort was called on |
| 95 | |
| 96 | np.ma.argsort has a long-term bug where the default of the axis argument |
| 97 | is wrong (gh-8701), which now must be kept for backwards compatibility. |
| 98 | Thankfully, this only makes a difference when arrays are 2- or more- |
| 99 | dimensional, so we only need a warning then. |
| 100 | """ |
| 101 | if arr.ndim <= 1: |
| 102 | # no warning needed - but switch to -1 anyway, to avoid surprising |
| 103 | # subclasses, which are more likely to implement scalar axes. |
| 104 | return -1 |
| 105 | else: |
| 106 | # 2017-04-11, Numpy 1.13.0, gh-8701: warn on axis default |
| 107 | warnings.warn( |
| 108 | "In the future the default for argsort will be axis=-1, not the " |
| 109 | "current None, to match its documentation and np.argsort. " |
| 110 | "Explicitly pass -1 or None to silence this warning.", |
| 111 | MaskedArrayFutureWarning, stacklevel=3) |
| 112 | return None |
| 113 | |
| 114 | |
| 115 | def doc_note(initialdoc, note): |