-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
table.table fails with KeyError (legacy python and mpl 2.2.0 only) #10740
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
Comments
cc @tacaswell this came up in the pandas tests, but this example only uses NumPy. One other thing to note, the code works fine when the data are not transposed. i.e. import numpy as np
import matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
data = np.random.randn(10, 3)
rowLabels = list('abcdefghij')
colLabels = [0, 1, 2]
table = matplotlib.table.table(ax, cellText=data, rowLabels=rowLabels,
colLabels=colLabels)
fig.savefig('foo.png') Doesn't throw an error on 2.7. Not sure if that helps or is just a red herring. |
This looks like a bug in Really odd that it only shows up with table..... attn @anntzer |
Right now I have no idea what is happening. Would suggest just reverting #9677 in 2.2.1. if you don't know either. |
I intend to revert #9677 on the 2.2.x branch and then deal with the merge-to-master conflicts. |
I don't know what's up with the error, but the non-transposed version does not fail simply because it hits the cache less. Probably it's because with a 3 column table, most of the rows end up off the figure and clipped. The crash is definitely related to the cache being full, but I don't know why it fails with the backport and not the Python 3 version. Since all calls are using essentially the same font properties, the only thing that can change is
The one with 17 calls is the one that raises. However, the first 16 instances are within the first 22 calls, and the failure is at call 296. So there's either a bug of evicting stuff from the cache earlier or at this point. A workaround we could use is to pass |
OK, so it turns out the difference between the two is that non-transposed can fit all text without shrinking text, so it always asks for 10 pt text, which never overflows the cache. With the transposed table, the text does not fit, so it tries 10 pt, then decreasing sizes until it fits, which seems to be 3 pt, making for 8 times as many calls that miss the cache more often as it fills much quicker. So easy workaround is to set the font size explicitly yourself: |
This reverts commit 5730794, reversing changes made to 1ca3d1a. Fixes matplotlib#10740 by avoiding suspected bugs in backports.lru_cache
closed by #10804 |
Bug report
Bug summary
In matplotlib 2.2 with python 2.7, the following code raises a KeyError. It succeeded in 1.5.3
Code for reproduction
Actual outcome
Expected outcome
Same as mpl 2.2
Matplotlib version
Installed from wheels of PyPI.
The text was updated successfully, but these errors were encountered: