-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix log transforms (fixes #3809) [back port to 1.4.x] #3863
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
Could do with a test. 😉 |
Does this also fix the documentation? |
a340546
to
b5685f4
Compare
Yes, it should also fix the documentation. In terms of test, are you essentially thinking of running the code snippet in the description of #3809 to ensure that it doesn't raise an exception? |
There is also a "bug report" of sorts in the mailing list from about a On Sat, Nov 29, 2014 at 12:35 PM, maxalbert notifications@github.com
|
Found it... could this possibly fix #3540? On Sat, Nov 29, 2014 at 12:37 PM, Benjamin Root ben.root@ou.edu wrote:
|
@maxalbert Yes, @cleanup
def test_log_transform():
fig, ax = plt.figure()
ax.set_yscale('log') # <--- works fine without this line
ax.transData.transform((1,1)) # <--- exception thrown here Would be good enough. The |
…o ensure we have a 2D array to avoid further case distinctions below.
…o a 2d array before applying any transforms and then convert the result back to the original shape.
@tacaswell Thanks! I have updated this PR with the suggested test. I had hoped that with the fix in #3866 it would just work, but it turns out that there were still problems because some (most?) of the transformation code on the Python side assumes that the input values are 2d. I can see two solutions to this: (1) Do not support transforming a single point but always require the input to be a list of points. This would at least ensure consistency, but it would be somewhat unintuitive for the user and also require changes in the documentation. (2) Support transforming a single point. This feels nicer from a user's point of view so I have chosen it for the current PR. My current solution in order to avoid messing with too much of the existing code is to unconditionally convert the input to a 2d array in |
I think this is looking good. Thanks @maxalbert. @mdboom - would you mind commenting? |
@WeatherGod I just double-checked but unfortunately this does not fix #3540. |
Thanks for this. I'm concerned about the performance impact of this pretty central piece of code -- but I have no suggestion to improve it. As I mentioned in #3866 I'm not crazy about the way |
I was wondering about the performance impact as well so I just did some quick-and-dirty profiling in IPython. I'm simply using import matplotlib.pyplot as plt
fig, ax = plt.subplots() as the setup and am timing various transforms by applying
so it looks reasonably complicated. Do you think it's representative for a typical transform? Anyway, here are the results: Current master:
On branch fix_log_transforms:
These numbers are pretty reproducible. It looks like transforming a single point is actually faster now. There is a slight overhead for 2d arrays but it doesn't appear to be huge, so hopefully we won't see too much of a performance impact for now. I take your point about treating the single-point case differently, though. I guess ultimately it's a tradeoff of user convenience vs. code tidiness (and perhaps performance). You core developers certainly have a much better feeling for what's best in this situation and I'm happy to go with that. If there is a consensus that single-point transforms shouldn't be supported despite this being a (slight) inconvenience for users then I'm happy to scrap this PR and open a new one. |
Thanks for the timings. I should have mentioned that my concerns were purely theoretical -- it's nice to have solid numbers. I think the thing to do is to merge this now (now that my timing concerns are mostly assuaged), and consider changing the API later in a more considered way. In a sense, this is just a bugfix at this point. |
Just my two cents, I think it makes sense to accept single points as On Fri, Dec 5, 2014 at 9:39 AM, Michael Droettboom <notifications@github.com
|
Fix log transforms (fixes #3809).
Fix log transforms (fixes #3809). Conflicts: lib/matplotlib/tests/test_transforms.py cherry-pick diff picked up too many tests in test_transforms.py
backported as 9d97a21 |
No description provided.