-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fixed transform=None behaviour on Artists. #1431
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
Ok. Looking at this, I think it is a viable alternative to #1326, so feel free to fire back any review actions. Thanks, |
See my comments in #1326 -- looks good to me |
Thanks @ChrisBeaumont, very helpful. @ChrisBeaumont wrote:
My only concern with this is that it is technically new functionality that wasn't in v1.1.1. Given the late hour, I would rather not do that. Perhaps we should think more about this functionality and target it for v1.3 - potentially we could introduce a nicer syntax (maybe allow the use of @mdboom , @dmcdougall et al. I think this is ready for merge. Cheers, |
Fixed transform=None behaviour on Artists.
The following code prints "True", and I think that is due to this change. import matplotlib.patches as mpatches
p = mpatches.Rectangle((0, 0), 1, 1)
a = p.get_transform()
print p.is_transform_set() |
Logically, I cannot see how can you I've fixed problems relating with this change in streamplot & legend in the past, is there a specific case which is now not working for you? Cheers, |
I would say "implicitly set" the transform in this case. The original behavior which only sets the "_transform" attribute is okay, but setting the "_transformSet" attribute, I am not sure. According to the documentation def is_transform_set(self):
"""
Returns *True* if :class:`Artist` has a transform explicitly
set.
""" I am not sure if calling "get_transform" is considered to set the transform "explicitly". The current behavior introduces a bug in one of my module. I can easily workaround this but want to make sure if calling the "set_transform" method (instead of setting "_transform" attribute directly) inside "get_transform" is a necessary change. |
Ok, that is a reasonable definition.
There are tests that depend on it, although I think there are ways of implementing HTH |
@pelson: my question is why, in the first place, you introduced this change.
|
I've spent a couple of minutes looking over this and it's not clear to me. I'll run the tests to see if there is a test which gets caught, otherwise I'd be fine with reverting it. |
Out of curiosity: is there a compelling reason to distinguish between explicit and implicit transform setting? That seems like a particularly subtle and hard-to-enforce policy. My inclination would have been to change the documentation (remove "explicitly") instead of the code. |
@ChrisBeaumont : When an artist is added to an axes, the transform of the artist is set to the data transform of the axes by default, unless the artist's transform attribute has been "explicitly set". And there are cases when we want to call the "get_transform" method before the artist is added to an axes (in this case, the method returns an identity transform). Still, when this artist is added to an axes later, its transform should be overridden to the data transform. Current code prevents this. So, as far as I can see, the documentation is right and the code needs to be fixed. @pelson: My tests with the above line reverted passes all relevant tests (I have one fail not related to this). And I think we'd better not to change the original behavior of "get_transform" method. So, I would very much appreciate if you revert this change. Reverting this may break something, but I would say that something needs to be fixed, not the "get_transform" method. |
There is a caveat to that - if you define transform=None in the Artist creation, you are explicitly saying that the Artist's transform is Identity. These cases are all tested in Thanks, |
Nudge: #1790 |
Fixes problem raised in #1431 (```get_transform``` should not affect ```is_transform_set```)
Alternative to #1326.