-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make Artist.set() apply properties in the order in which they are given. #16328
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
I would think that doing the inverse, namely to ignore the order and instead always evaluate the parameters in the same hierarchical order would be much cleaner. Meaning, I don't think the following two
should ever result in a different output. |
FWIW in #5599 (comment) it was explicitly chosen that |
My point is that for a user-facing API, it's quite unusual to rely on ordering. And if you create your parameters dynamically, you might not even know their order (e.g. a downstream library assembling properties on the fly, possibly allowing users to pass in further kwargs). |
original doesn't beat alias -- we error out if both are passed. |
That's fine. Although a clear rule would make people's lifes easier, if e.g. they could just
I guess that would be the consequence, yes. If some API is going to break for 4.0 anyways, this might be a good point to do it.
Many docstrings are interpolated anyways, so that should be the least of a problem. In general, I just think this warrants a little more discussion - possibly there are good arguments against that proposal, which I don't see at the moment. |
For me, what really matters is consistency and clarity. |
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 can understand the argument for establishing some fixed ordering, but "put them in the order you want them" is so much simpler, and fits the idea of set()
as a shorthand for listing a sequence of clunky set_this
function calls.
Needs rebase, but I don't see any reason not to put this into v3.3, so I moved up the milestone. |
... with a deprecation period (see changelog). - This is consistent with Artist.update, and we don't reorder separate calls to set_color and set_edgecolor either (we can't really to that, indeed). - The _prop_order mechanism was a slightly complex machinery for a single use case (applying "color" first). - Writing `p.set(edgecolor="r", color="g")` seems a bit twisted anyways. Also rewrote (and simplified) normalize kwargs to make it *also* maintain kwarg order, as that's necessary to make the warning emitted in the correct cases.
rebased |
... with a deprecation period (see changelog).
calls to set_color and set_edgecolor either (we can't really to that,
indeed).
single use case (applying "color" first).
p.set(edgecolor="r", color="g")
seems a bit twisted anyways.Also rewrote (and simplified) normalize kwargs to make it also
maintain kwarg order, as that's necessary to make the warning emitted in
the correct cases.
PR Summary
PR Checklist