Skip to content

Commit 1ffaf41

Browse files
QuLogictimhoffm
authored andcommitted
Remove ticks and titles from tight bbox tests. (matplotlib#12790)
These text elements may shift with different versions of FreeType, making the tight bbox results unstable when building against external newer versions.
1 parent bd7829d commit 1ffaf41

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import warnings
1717

1818
import matplotlib
19-
from matplotlib.testing.decorators import image_comparison, check_figures_equal
19+
from matplotlib.testing.decorators import (
20+
image_comparison, check_figures_equal, remove_ticks_and_titles)
2021
import matplotlib.pyplot as plt
2122
import matplotlib.markers as mmarkers
2223
import matplotlib.patches as mpatches
@@ -5913,9 +5914,10 @@ class DummySubplot(matplotlib.axes.SubplotBase, Dummy):
59135914

59145915
def test_gettightbbox_ignoreNaN():
59155916
fig, ax = plt.subplots()
5917+
remove_ticks_and_titles(fig)
59165918
t = ax.text(np.NaN, 1, 'Boo')
59175919
renderer = fig.canvas.get_renderer()
5918-
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 532.444444)
5920+
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 496)
59195921

59205922

59215923
def test_scatter_series_non_zero_index(pd):

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import matplotlib
22
import matplotlib.pyplot as plt
3-
from matplotlib.testing.decorators import image_comparison
3+
from matplotlib.testing.decorators import (
4+
image_comparison, remove_ticks_and_titles)
45

56
from mpl_toolkits.axes_grid1 import host_subplot
67
from mpl_toolkits.axes_grid1 import make_axes_locatable
@@ -409,7 +410,6 @@ def test_image_grid():
409410

410411

411412
def test_gettightbbox():
412-
413413
fig, ax = plt.subplots(figsize=(8, 6))
414414

415415
l, = ax.plot([1, 2, 3], [0, 1, 0])
@@ -418,6 +418,8 @@ def test_gettightbbox():
418418
ax_zoom.plot([1, 2, 3], [0, 1, 0])
419419

420420
mark_inset(ax, ax_zoom, loc1=1, loc2=3, fc="none", ec='0.3')
421+
422+
remove_ticks_and_titles(fig)
421423
bbox = fig.get_tightbbox(fig.canvas.get_renderer())
422424
np.testing.assert_array_almost_equal(bbox.extents,
423-
[-18.022743, -14.118056, 7.332813, 5.4625])
425+
[-17.7, -13.9, 7.2, 5.4])

0 commit comments

Comments
 (0)