-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Parameter-renaming decorator #13128
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
Parameter-renaming decorator #13128
Conversation
Actually @efiring argued in #12383 (comment) against the s->text change; I personally don't really mind either way and can revert it here if that's the agreement. |
Looks like it interacts with pyplot in a bit of a weird way too... |
Regarding my earlier comment in favor of "s": I'm willing to back off on that. It probably does make more sense at this point for |
@@ -6903,7 +6905,7 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, | |||
""" | |||
|
|||
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, | |||
normed=normed, weights=weights) | |||
normed=density, weights=weights) |
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.
Wouldn't it be "density=density"?
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.
no, it's called normed on hist2d side until np 1.15... #11070 (comment)
I see your point @tacaswell re: pyplot. I think everything can be made to work, just needs a bit more care... |
fa1183c
to
124a8b1
Compare
Went for a different, and in fact much simpler implementation (turns out the pyplot wrappers really constrain the design space here). |
124a8b1
to
a5c083f
Compare
a5c083f
to
c8b396c
Compare
c8b396c
to
842a12c
Compare
Could you also add a |
That's actually going to be harder wrt. the pyplot wrappers, I think(?), because that decorator probably really needs to be applied on the wrapper as well (as the wrappers pass everything down by keyword, so the inner function cannot check whether the argument was passed positionally to the wrapper), and I tried quite hard (both here and in #13173) to not "store additional information" on the method to tell whether the wrapper needs additional decorators. Edit: IIRC we can't make the pyplot wrappers just take
with
i.e. the decorator actually completely ignores the implementation of the wrapper and directly forwards the arguments to the method instead... now the method will know whether the argument was passed positionally or as keyword, and the "deprecate_passing_positionally" decorator will work. |
I don't think it would be terrible for the pyplot generating code to be aware of our deprecation decorators to a sufficient degree that it could re-write them into the generated code. That would be nice for the humans who look at the code in pyplot. On the other hand, reducing the bodies of the functions in pyplot to |
Now that I think of it, one main argument for moving to keyword-only arguments is to make it easier to rename or to delete arguments, but now that this PR and #13173 implement these features, I guess it's not that useful anymore? |
842a12c
to
45a3ea1
Compare
This seems fine to me, but I don't think it should be merged unless @tacaswell and/or @efiring approve.
I guess thats true, but I think its also better to make the interface explicit to get rid of the magic guessing we do about what each arg means. |
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 looks fine to me. It affects only a few places for now, so if some horrible disadvantage of it turns up, or a much better approach is found, it will be easy to revert. I don't expect that, though. It looks pretty clean and simple.
Good to merge? :) |
I'd like @tacaswell to merge. I think we should also decide some sort of guidelines for renaming... Just because this is easier dosn't mean we should break old documentation and examples on webpages... |
I think it should be treated as an API break like most others, although with a lower bar if we can reasonably assume that the parameter was rarely if ever passed as keyword (e.g. |
ping @tacaswell - I'll merge if don't hear from you by w/e |
45a3ea1
to
17376c1
Compare
(force push: replaced "argument" by "parameter" in the changelog, for consistency with the decorator name, see also https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter) |
17376c1
to
90b0f4d
Compare
PR Summary
xref #13117 (comment), #11070, #12563, #12383.
attn @tacaswell @timhoffm I guess.
Edit: hum, probably needs a bit more thought to handle the case of **kwargs silently grabbing all unknown kwargs...
Edit: fixed.
PR Checklist