Repository navigation
MNT: unify code path of set, update, setp - #5599
Conversation
|
A follow on to this might be to implement a priority lookup to sort the key/value pairs instead of alphabetical sorting, but I am not sure if that is replicating functionality already in traitlets. |
|
I would be +1 on implementing a proper lookup order. The reversed(IIRC) On Tue, Dec 1, 2015 at 11:35 AM, Thomas A Caswell [email protected]
|
There was a problem hiding this comment.
loop up how to ? (I think?) The sentence is a little unclear.
Single code path for the property -> setter lookup logic.
There was a problem hiding this comment.
Maybe this could be an embedded function in update(), since it isn't used from anywhere else?
There was a problem hiding this comment.
good point, when I started I didn't think I would be able to use update everywhere else.
There was a problem hiding this comment.
on second thought, wouldn't that result in re-defining the function everytime through call to update?
There was a problem hiding this comment.
No -- Python will compile the function only once -- it only redefines the local variables each time.
4f8343b to
63f4437
Compare
There was a problem hiding this comment.
The sorting by key name is just to prevent any non-deterministic behavior?
There was a problem hiding this comment.
and makes color/facecolor/edgecolor go in the right order.
There was a problem hiding this comment.
Partly. It is also to have a priority structure. If someone defines both
"color" and "facecolor" at the same time, the current behavior is for color
to take precedence over facecolor, IIRC.
On Tue, Dec 1, 2015 at 11:51 AM, Michael Droettboom <
[email protected]> wrote:
In lib/matplotlib/artist.py
#5599 (comment):@@ -845,21 +845,46 @@ def update(self, props):
"""
store = self.eventson
self.eventson = False
changed = Falsetry:ret = [self._update_property(k, v)for k, v in sorted(props.items(), reverse=True)]The sorting by key name is just to prevent any non-deterministic behavior?
—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/5599/files#r46304017.
|
This is cool, and I'm always happy to see PRs that reduce total lines of code ;) Maybe this is a minor point, but it seems that |
Hide private helper method more thoroughly.
|
I changed a list to a set literal, this can not be back-ported to 1.5.x. |
|
Agree with @mdboom. Let setp be the only place where sorting happens. I On Tue, Dec 1, 2015 at 11:55 AM, Michael Droettboom <
|
restore old behavior
Make one call to `update` with the ordered dict rather than one call per element.
Add the ability to set the precedence of properties when updating multiple properties on once. This adds a class-level attribute `Artist._prop_order` which is a dictionary keyed on property names with integer values. When using `set` or `setp` the properties will be applied in descending order by value then by name.
|
If we're concerned about subtle changes in behavior, the new zero-tolerance test suite seems to be pretty good at rooting that out. @tacaswell: if you wanted, you could base this on my zero tolerance branch and see if any additional tests are failing beyond the dozen or so that are failing on that branch presently. |
|
Ended up landing on |
|
I rebased it locally and have the same 11 failures. |
55370f8 to
1905607
Compare
|
Any further thoughts on this? I am tempted to rip the |
MNT: unify code path of set, update, setp
Single code path for the property -> setter lookup logic.
attn @mdboom