DEP: deprecate calling ma.argsort without an axis#8918
Conversation
9da0a5b to
1075c1d
Compare
|
|
||
|
|
||
| class TestArgsort(TestCase): | ||
| """ gh-8701 """ |
There was a problem hiding this comment.
Should include date and numpy version, that helps keep track of expiration dates, etc.
There was a problem hiding this comment.
Thought that having it repeated in the tests would just be noise - date and version are already in the source
numpy/ma/core.py
Outdated
| # no warning needed - switch to -1 to avoid surprising subclasses | ||
| return -1 | ||
| else: | ||
| # 2017-04-10, numpy 1.13.0 |
There was a problem hiding this comment.
Date and version are here - should they be repeated at the call site as well?
There was a problem hiding this comment.
And a related idea - maybe we should have a custom np.DeprecationWarning with version and date fields?
There was a problem hiding this comment.
I usually grep for the date and version to find what needs to be changed after branching a version, so whatever should be easily grepable and location specific. I think it is not too much work to just add a comment.
numpy/ma/core.py
Outdated
|
|
||
| """ | ||
|
|
||
| axis = _deprecate_argsort_axis(self, axis) |
There was a problem hiding this comment.
Add note with date and numpy version, something like
# 04-11-2017, Numpy 1.13.0, warn on axis default.
There was a problem hiding this comment.
Should I remove that comment from inside _deprecate_argsort_axis itself then?
There was a problem hiding this comment.
Doesn't matter, but really the information needs to be at the point of call.
numpy/ma/core.py
Outdated
|
|
||
| def _deprecate_argsort_axis(arr, axis): | ||
| """ | ||
| Takes the array argsort was called upon, and the axis argument |
There was a problem hiding this comment.
Should follow usual docstring standard. This is really something for the Parameters section.
numpy/ma/core.py
Outdated
| else: | ||
| # 2017-04-10, numpy 1.13.0 | ||
| warnings.warn( | ||
| "Unlike np.argsort, np.sort, np.ma.sort, and the " |
There was a problem hiding this comment.
Can shorten this message, I'd just say the in the future the default axis will be -1 to match the documentation, not the current None and omit the unlike bit.
There was a problem hiding this comment.
Not worth keeping the "pass the axis explicitly to squash" bit?
There was a problem hiding this comment.
Can keep that. There is temptation is to explain "why", which is good for a commit message, but documentation should mosty be "what".
There was a problem hiding this comment.
Should also mention the change in the function axis documentation with a note about the deprecation.
There was a problem hiding this comment.
How do you recommend I word that?
There was a problem hiding this comment.
Should we keep the part that says "the default is -1", despite it being wrong?
There was a problem hiding this comment.
Maybe
The default value is None. Prior to NumPy 1.13.0 the
default was documented to be -1, but that was in error.
However, we intend to make the default -1 for real at
some future date, and so issue a FutureWarning unless
the axis is explicitly given for arrays of dimension > 1.
There was a problem hiding this comment.
Note that I think a simple FutureWarning would suffice rather than the temporary two off MaskedArrayFutureWarning.
There was a problem hiding this comment.
Are we reserving MaskedArrayFutureWarning for the incoming "mask is the same type of view/non-view as data" change then?
There was a problem hiding this comment.
The benefit of having a MaskedArrayFutureWarning is that it makes it obvious that the warning only applies to masked arrays, and the message doesn't need to explain that only ma.argsort has a bad default argument
|
Need to finish this up. |
b2b3a0b to
056816c
Compare
numpy/ma/core.py
Outdated
There was a problem hiding this comment.
This level needed to be 3, not 2, as it is not directly in the deprecated function
numpy/ma/core.py
Outdated
There was a problem hiding this comment.
Doing the test here makes it more obvious that this only affects default arguments
056816c to
844d4f7
Compare
numpy/ma/core.py
Outdated
There was a problem hiding this comment.
Added the comment to the axis argument
|
Fun fact: |
|
☔ The latest upstream changes (presumably #8996) made this pull request unmergeable. Please resolve the merge conflicts. |
Only deprecated when this would be ambiguous. Approaches numpy#8701
844d4f7 to
0a8ee4c
Compare
Rebased to fix the merge conflict |
|
Thanks Eric. |
This does not match np.maximum, which is confusing because the masked version has no documentation at all. This uses a similar deprecation approach to numpygh-8918, noting that the warning is only needed for arrays of more than one dimension. The same remarks apply to `np.ma.minimum`
Introduced by me in numpy#8918
This does not match np.maximum, which is confusing because the masked version has no documentation at all. This uses a similar deprecation approach to numpygh-8918, noting that the warning is only needed for arrays of more than one dimension. The same remarks apply to `np.ma.minimum`
Introduced by me in numpy#8918
Only deprecated when this would be ambiguous.
Approaches #8701