Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG Ignore invisible axes in computing tight_layout #8244
Conversation
tacaswell
added this to the
2.0.1 (next bug fix release)
milestone
Mar 8, 2017
|
This only fails pep8: |
|
Gotcha. @tomspur Presumably I should add a test somewhere too, right? These CIs are taking five-ever... |
|
Yes, a test/picture helps to understand this issue and stops from breaking it again :) |
| @@ -157,6 +158,15 @@ def test_tight_layout8(): | ||
| example_plot(ax, fontsize=24) | ||
| +@image_comparison(baseline_images=['tight_layout9']) | ||
| +def test_tight_layout9(): |
ResidentMario
Mar 10, 2017
Contributor
Bear with me here, I have no idea how matplotlib handles its tests.
| @@ -123,6 +123,9 @@ def auto_adjust_subplotpars(fig, renderer, | ||
| for subplots, ax_bbox, (num1, num2) in zip(subplot_list, | ||
| ax_bbox_list, | ||
| num1num2_list): | ||
| + if all([not ax.get_visible() for ax in subplots]): |
tacaswell
Mar 10, 2017
Owner
shouldn't this just be filtering out invisible axes? subplots = [ax for ox in subplots if ax.get_visible()]
Would it make more sense to make sure what ever calls method does that filtering?
WeatherGod
Mar 10, 2017
Member
yeah, I don't understand why you changed what I originally suggested. I suggested putting a filter in the list comprehension down below. Now, it does make sense to skip this iteration if all the axes in this group are invisible. So, I would put the filter in the list comprehension down below, and also change this one from a any to an all.
WeatherGod
Mar 10, 2017
Member
grrr, I fail reading comprehension... you do have a all. But the filter should still be down below.
ResidentMario
Mar 10, 2017
•
Contributor
The first commit tried that approach (see here).
But it actually failed to fix the issue. If you try to use that code with the original minimal failing example:
import matplotlib.pyplot as plt
f, axarr = plt.subplots(2, 2)
axarr[1][1].set_visible(False)
plt.tight_layout()The union op will fail because the list comprehension will pass it an empty list ([]).
ResidentMario
Mar 10, 2017
Contributor
Before making a PR, please check that your commit actually fixes the issue...ahem.
Skipping the laying calculations altogether (the approach here) meanwhile seems to work.
WeatherGod
Mar 10, 2017
Member
Yes, that's why you need both approaches. if a subset of the subplots are not visible, then the way the code is currently, the invisible axes still have get_tightbbox called on them, which would also fail. You need to protect that (my original approach), and protect from a union() call on an empty list (your current approach).
ResidentMario
Mar 10, 2017
Contributor
OK, I understand you now—I've re-added the conditional check.
|
attn @NelleV @anntzer @Kojoley Something is going wrong with pytest here. Running this locally I get:
I would expect the three xfail to be real fails (due to missing files). |
|
This is the culprit (decorators.py, copy_baseline):
I would just remove that chunk and replace by a real fail in the actual test function. |
|
See #8262 for a fix to my previous comment, sorry to have hi-jacked this PR with other issues. |
|
Always happy to be breaking things productively. |
ResidentMario
added some commits
Mar 10, 2017
|
This passes tests locally, except for an unrelated error in |
|
We have some flaky test, so we sometimes restart some tests by hand (hence travis rerunning magically :) ) |
|
All green. LGTM? |
tacaswell
approved these changes
Mar 12, 2017
Only concern would be if we really need the image comparison tests here. The bug it is fixing is 'do raise'.
NelleV
merged commit 27f6781
into matplotlib:master
Mar 12, 2017
5 checks passed
|
Thanks @ResidentMario ! |
ResidentMario
deleted the
ResidentMario:8225 branch
Mar 12, 2017
This was referenced Mar 12, 2017
| @@ -157,6 +158,15 @@ def test_tight_layout8(): | ||
| example_plot(ax, fontsize=24) | ||
| +@image_comparison(baseline_images=['tight_layout9']) | ||
| +def test_tight_layout9(): |
WeatherGod
Mar 16, 2017
Member
There are now two test functions in one file with the same name. So the first one gets clobbered by the second one.
WeatherGod
Mar 16, 2017
•
Member
Sorry, please ignore. I misread test_tight_layout8 as test_tight_layout9. Really need to fix the default fonts on this computer...
QuLogic
added the
Needs backport
label
Mar 16, 2017
QuLogic
added a commit
to QuLogic/matplotlib
that referenced
this pull request
Mar 27, 2017
|
|
NelleV + QuLogic |
3ff1153
|
QuLogic
removed the
Needs backport
label
Mar 27, 2017
|
Backported to |
ResidentMario commentedMar 8, 2017
cf. #8225
Should pass tests. But, we'll see. Maybe this has side-effects.