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