-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
DEP: adjust deprecation of positional arguments #18624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're extending the deprecation by two releases, I'd like to fully deprecate positional use of all kwargs along the lines of #14714. Example below.
@@ -531,7 +532,7 @@ def simps(y, x=None, dx=1.0, axis=-1, even=None): | |||
return simpson(y, x=x, dx=dx, axis=axis, even=even) | |||
|
|||
|
|||
def simpson(y, x=None, dx=1.0, axis=-1, even=None): | |||
def simpson(y, x=None, dx=1.0, axis=-1, even=_NoValue): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how things would look like after switching to keyword-only args.
def simpson(y, x=None, dx=1.0, axis=-1, even=_NoValue): | |
def simpson(y, *, x=None, dx=1.0, axis=-1): |
In the meantime, we should probably vendor the helper that scikit-learn came up with to do the deprecation of positional use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am +1000 there!
@@ -522,7 +523,7 @@ def _basic_simpson(y, start, stop, x, dx, axis): | |||
|
|||
# Note: alias kept for backwards compatibility. simps was renamed to simpson | |||
# because the former is a slur in colloquial English (see gh-12924). | |||
def simps(y, x=None, dx=1.0, axis=-1, even=None): | |||
def simps(y, x=None, dx=1.0, axis=-1, even=_NoValue): | |||
"""An alias of `simpson`. | |||
|
|||
`simps` is kept for backwards compatibility. For new code, prefer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sidenote: this alias sounds like it should eventually be removed. Looking at the above-mentioned #12924, it's even more of a candidate for deprecation and removal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like this is trying to reopen the gh-14714 discussion, and it's not really related to the topic of this PR - which is only about ensuring warnings for already deprecated keywords are always emitted. I'd suggest not mixing new deprecations into this PR. |
You're deprecating the |
OK, that means, I'll wait for a deprecation cycle starting from 1.12 to 1.14 if anybody sets tol with positional arg which is your example. Then 1.14 rips That was the part I didn't parse in this discussion. |
That's gonna need an additional deprecation for those people feeding the current kwargs positionally. This is what the above-promised issue will be about, because doing that deprecation is more involved (if starting from scratch, which is why we should build on the work from scikit-learn on this). So no |
This is right.
It may not, depending on the details - in @ilayn's case I think this does not require an additional deprecation since bicg(A, b, x0=None, tol=None, maxiter=None, M=None, callback=None, atol=0., rtol=1e-5) New signature for 1.14.0 with only the deprecation that's already there plus the # You may also reorder the keywords at that point if you desire to do so for clarity
bicg(A, b, x0=None, *, maxiter=None, M=None, callback=None, atol=0., rtol=1e-5) There's of course more issues (e.g. # Order these keywords from most to least used
bicg(A, b, /, *, guess=None, atol=0., rtol=1e-5, maxiter=None, preconditioner=None, callback=None)
@h-vetinari perhaps you can follow up with a minor concrete tweak to @ilayn's deprecation message? I suspect it may be annoying to get that right (because you don't know when it applies without more introspection) and it may not be worth it, but please do try to make it concrete, because it'll be obvious once you actually try. |
Ah OK it's much clearer for me now too. This PR looks indeed then ready to go, and we can do some follow ups right after this. 1.12 looks like the big clean-up with all the fortran, signatures, and deprecations and so on :) Let me take the discussion to #18488 then and what it would take to mark it as down. |
In the spirit of decoupling the details of the "deprecate positional use" from the current PRs, how about we deal with it more holistically in a separate issue/PR (but definitely for 1.12)? That way, all the existing PRs have to do is use |
Sounds good to me! |
@j-bowhay Oops, I created a conflict, sorry about that. In the meantime, I'm preparing another PR for iterative kwargs having |
@ilayn I have hopefully addressed all @rgommers comments so this should be good to go if it comes back green. I ended up removing any of the changes to the iterative solver as I thought it would be easier to add it to your pr and do them all at once rather than hunt through the merge conflicts for my changes |
|
Just to confirm, is everyone happy to click the button about this? |
All thumbs up from the participants and thanks all for the discussions. It is quite informative for me too. |
Reference issue
#18578 (comment)
What does this implement/fix?
In the past, when deprecating an argument to a function that we want to remove, we have used the argument being different from the default value of
None
to trigger the deprecation warning. However, as pointed out by @rgommers, the current method we are using to deprecate arguments we want to remove was not entirely watertight if the user uses all positional arguments.As an example,
kendalltau(x, y, None, 'omit', 'exact')
would not raise the deprecation warning so we are in danger of breaking the user's code without warning if this was removed directly. Side note, this is yet another reason why making new code use keyword-only arguments when applicable is desirable.As per @rgommers suggestion, I have added a private
_NoValue
object which is used to trigger the deprecation warning. This means now:as required to remove the argument.
Additional information
cc @h-vetinari