diff --git a/doc/api/next_api_changes/behavior/31148-ES.rst b/doc/api/next_api_changes/behavior/31148-ES.rst new file mode 100644 index 000000000000..08ad9b7cb0c1 --- /dev/null +++ b/doc/api/next_api_changes/behavior/31148-ES.rst @@ -0,0 +1,6 @@ +Default *style* parameter of ``image_comparison`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The *style* parameter of the `.image_comparison` decorator will become 'mpl20' in +Matplotlib 3.13. Not passing it and relying on the previous default will warn until the +change occurs. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index a7bdc9d28347..1ba5e9522436 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1374,6 +1374,11 @@ def _init_tests(): ft2font.__freetype_version__, "" if ft2font.__freetype_build_type__ == 'local' else "not ") + # Generate a shortcut for classic testing style. + from matplotlib.style import _base_library, library + _base_library['_classic_test'] = library['_classic_test'] = RcParams( + _base_library['classic'] | _base_library['_classic_test_patch']) + def _replacer(data, value): """ diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index f404d7ae84ee..c5f810f01f46 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -14,7 +14,7 @@ import matplotlib.style import matplotlib.units import matplotlib.testing -from matplotlib import _pylab_helpers, cbook, ft2font, pyplot as plt, ticker +from matplotlib import _api, _pylab_helpers, cbook, ft2font, pyplot as plt, ticker from matplotlib.figure import Figure from .compare import comparable_formats, compare_images, make_test_filename from .exceptions import ImageComparisonFailure @@ -263,8 +263,7 @@ def wrapper(*args, extension, request, **kwargs): def image_comparison(baseline_images, extensions=None, tol=0, freetype_version=None, remove_text=False, savefig_kwarg=None, - # Default of mpl_test_settings fixture and cleanup too. - style=("classic", "_classic_test_patch")): + style=None): """ Compare images generated by the test with those specified in *baseline_images*, which must correspond, else an `.ImageComparisonFailure` @@ -316,9 +315,13 @@ def image_comparison(baseline_images, extensions=None, tol=0, Optional arguments that are passed to the savefig method. style : str, dict, or list - The optional style(s) to apply to the image test. The test itself - can also apply additional styles if desired. Defaults to ``["classic", - "_classic_test_patch"]``. + The style(s) to apply to the image test. The test itself can also apply + additional styles if desired. + + .. versionchanged:: 3.11 + This defaults to ``['classic', '_classic_test_patch']``, but will be + changing to ``'mpl20'`` as of Matplotlib 3.13. A warning is raised if not + explicitly passed. """ if baseline_images is not None: @@ -342,6 +345,12 @@ def image_comparison(baseline_images, extensions=None, tol=0, extensions = ['png', 'pdf', 'svg'] if savefig_kwarg is None: savefig_kwarg = dict() # default no kwargs to savefig + if style is None: + _api.warn_external( + 'The default for the style parameter of image_comparsion() will be ' + 'changing to "mpl20" in Matplotlib 3.13; explicitly pass style to continue ' + 'working as before and suppress this warning.') + style = ('classic', '_classic_test_patch') if sys.maxsize <= 2**32: tol += 0.06 return _pytest_image_comparison( diff --git a/lib/matplotlib/testing/decorators.pyi b/lib/matplotlib/testing/decorators.pyi index f1b6c5e595cb..1738794d119a 100644 --- a/lib/matplotlib/testing/decorators.pyi +++ b/lib/matplotlib/testing/decorators.pyi @@ -17,7 +17,7 @@ def image_comparison( freetype_version: tuple[str, str] | str | None = ..., remove_text: bool = ..., savefig_kwarg: dict[str, Any] | None = ..., - style: RcStyleType = ..., + style: RcStyleType | None = ..., ) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... def check_figures_equal( *, extensions: Sequence[str] = ..., tol: float = ... diff --git a/lib/matplotlib/tests/test_agg.py b/lib/matplotlib/tests/test_agg.py index 6eebde1da92b..c55f27e03a41 100644 --- a/lib/matplotlib/tests/test_agg.py +++ b/lib/matplotlib/tests/test_agg.py @@ -92,7 +92,7 @@ def test_long_path(): fig.savefig(buff, format='png') -@image_comparison(['agg_filter.png'], remove_text=True) +@image_comparison(['agg_filter.png'], remove_text=True, style='_classic_test') def test_agg_filter(): def smooth1d(x, window_len): # copied from https://scipy-cookbook.readthedocs.io/ diff --git a/lib/matplotlib/tests/test_arrow_patches.py b/lib/matplotlib/tests/test_arrow_patches.py index 08d3d62f0a84..7be2fcf6b1b0 100644 --- a/lib/matplotlib/tests/test_arrow_patches.py +++ b/lib/matplotlib/tests/test_arrow_patches.py @@ -11,7 +11,7 @@ def draw_arrow(ax, t, r): fc="b", ec='k')) -@image_comparison(['fancyarrow_test_image.png'], +@image_comparison(['fancyarrow_test_image.png'], style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.012) def test_fancyarrow(): # Added 0 to test division by zero error described in issue 3930 @@ -110,8 +110,8 @@ def __prepare_fancyarrow_dpi_cor_test(): @image_comparison(['fancyarrow_dpi_cor_100dpi.png'], remove_text=True, - tol=0 if platform.machine() == 'x86_64' else 0.02, - savefig_kwarg=dict(dpi=100)) + savefig_kwarg=dict(dpi=100), style='_classic_test', + tol=0 if platform.machine() == 'x86_64' else 0.02) def test_fancyarrow_dpi_cor_100dpi(): """ Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is @@ -125,8 +125,8 @@ def test_fancyarrow_dpi_cor_100dpi(): @image_comparison(['fancyarrow_dpi_cor_200dpi.png'], remove_text=True, - tol=0 if platform.machine() == 'x86_64' else 0.02, - savefig_kwarg=dict(dpi=200)) + savefig_kwarg=dict(dpi=200), style='_classic_test', + tol=0 if platform.machine() == 'x86_64' else 0.02) def test_fancyarrow_dpi_cor_200dpi(): """ As test_fancyarrow_dpi_cor_100dpi, but exports @ 200 DPI. The relative size diff --git a/lib/matplotlib/tests/test_artist.py b/lib/matplotlib/tests/test_artist.py index 976cbb4feae3..15fa5668a17c 100644 --- a/lib/matplotlib/tests/test_artist.py +++ b/lib/matplotlib/tests/test_artist.py @@ -96,7 +96,7 @@ def test_collection_transform_of_none(): assert isinstance(c.get_offset_transform(), mtransforms.IdentityTransform) -@image_comparison(["clip_path_clipping"], remove_text=True) +@image_comparison(["clip_path_clipping"], remove_text=True, style='_classic_test') def test_clipping(): exterior = mpath.Path.unit_rectangle().deepcopy() exterior.vertices *= 4 diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 5717283fccce..f006c624f8d7 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -441,7 +441,7 @@ def test_twin_logscale(fig_test, fig_ref, twin): remove_ticks_and_titles(fig_ref) -@image_comparison(['twin_autoscale.png'], +@image_comparison(['twin_autoscale.png'], style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.009) def test_twinx_axis_scales(): x = np.array([0, 0.5, 1]) @@ -635,7 +635,7 @@ def test_minorticks_on_rcParams_both(fig_test, fig_ref): ax_ref.minorticks_on() -@image_comparison(["autoscale_tiny_range.png"], remove_text=True) +@image_comparison(["autoscale_tiny_range.png"], remove_text=True, style='_classic_test') def test_autoscale_tiny_range(): # github pull #904 fig, axs = plt.subplots(2, 2) @@ -787,7 +787,7 @@ def test_basic_annotate(): xytext=(3, 3), textcoords='offset points') -@image_comparison(['arrow_simple.png'], remove_text=True) +@image_comparison(['arrow_simple.png'], remove_text=True, style='_classic_test') def test_arrow_simple(): # Simple image test for ax.arrow # kwargs that take discrete values @@ -1000,7 +1000,8 @@ def test_axhspan_epoch(): ax.set_ylim(t0 - 5.0*dt, tf + 5.0*dt) -@image_comparison(['hexbin_extent.png', 'hexbin_extent.png'], remove_text=True) +@image_comparison(['hexbin_extent.png', 'hexbin_extent.png'], remove_text=True, + style='_classic_test') def test_hexbin_extent(): # this test exposes sf bug 2856228 fig, ax = plt.subplots() @@ -1037,7 +1038,7 @@ def test_hexbin_string_norm(): assert hex.norm.vmax == 5 -@image_comparison(['hexbin_empty.png'], remove_text=True) +@image_comparison(['hexbin_empty.png'], remove_text=True, style='_classic_test') def test_hexbin_empty(): # From #3886: creating hexbin from empty dataset raises ValueError fig, ax = plt.subplots() @@ -1266,7 +1267,7 @@ def test_imshow_norm_vminvmax(): ax.imshow(a, norm=mcolors.Normalize(-10, 10), vmin=0, vmax=5) -@image_comparison(['polycollection_joinstyle'], remove_text=True) +@image_comparison(['polycollection_joinstyle'], remove_text=True, style='_classic_test') def test_polycollection_joinstyle(): # Bug #2890979 reported by Matthew West fig, ax = plt.subplots() @@ -1312,6 +1313,7 @@ def test_fill_betweenx_input(y, x1, x2): @image_comparison(['fill_between_interpolate.png'], remove_text=True, + style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.012) def test_fill_between_interpolate(): x = np.arange(0.0, 2, 0.02) @@ -1357,7 +1359,8 @@ def test_fill_between_interpolate_decreasing(): ax.set_ylim(800, 600) -@image_comparison(['fill_between_interpolate_nan.png'], remove_text=True) +@image_comparison(['fill_between_interpolate_nan.png'], remove_text=True, + style='_classic_test') def test_fill_between_interpolate_nan(): # Tests fix for issue #18986. x = np.arange(10) @@ -1389,7 +1392,7 @@ def test_symlog(): ax.set_ylim(-1, 10000000) -@image_comparison(['symlog2.pdf'], remove_text=True) +@image_comparison(['symlog2.pdf'], remove_text=True, style='_classic_test') def test_symlog2(): # Numbers from -50 to 50, with 0.1 as step x = np.arange(-50, 50, 0.001) @@ -1416,7 +1419,7 @@ def test_pcolorargs_5205(): plt.pcolor(X, Y, list(Z[:-1, :-1])) -@image_comparison(['pcolormesh'], remove_text=True, +@image_comparison(['pcolormesh'], remove_text=True, style='_classic_test', tol=0.11 if platform.machine() == 'aarch64' else 0) def test_pcolormesh(): # Remove this line when this test image is regenerated. @@ -1441,7 +1444,7 @@ def test_pcolormesh(): ax3.pcolormesh(Qx, Qz, Zm, shading="gouraud") -@image_comparison(['pcolormesh_small.eps']) +@image_comparison(['pcolormesh_small.eps'], style='_classic_test') def test_pcolormesh_small(): n = 3 x = np.linspace(-1.5, 1.5, n) @@ -1467,8 +1470,8 @@ def test_pcolormesh_small(): ax.set_axis_off() -@image_comparison(['pcolormesh_alpha'], extensions=["png", "pdf"], - remove_text=True, +@image_comparison(['pcolormesh_alpha'], extensions=["png", "pdf"], remove_text=True, + style='_classic_test', tol=0.4 if platform.machine() == "aarch64" else 0) def test_pcolormesh_alpha(): # Remove this line when this test image is regenerated. @@ -1825,7 +1828,7 @@ def test_arc_angles(): scale *= 10 -@image_comparison(['arc_ellipse'], remove_text=True) +@image_comparison(['arc_ellipse'], remove_text=True, style='_classic_test') def test_arc_ellipse(): xcenter, ycenter = 0.38, 0.52 width, height = 1e-1, 3e-1 @@ -1898,7 +1901,8 @@ def test_markevery_line(): ax.legend() -@image_comparison(['markevery_linear_scales.png'], remove_text=True, tol=0.001) +@image_comparison(['markevery_linear_scales.png'], remove_text=True, + style='_classic_test', tol=0.001) def test_markevery_linear_scales(): cases = [None, 8, @@ -1923,7 +1927,8 @@ def test_markevery_linear_scales(): plt.plot(x, y, 'o', ls='-', ms=4, markevery=case) -@image_comparison(['markevery_linear_scales_zoomed.png'], remove_text=True) +@image_comparison(['markevery_linear_scales_zoomed.png'], remove_text=True, + style='_classic_test') def test_markevery_linear_scales_zoomed(): cases = [None, 8, @@ -1950,7 +1955,7 @@ def test_markevery_linear_scales_zoomed(): plt.ylim((1.1, 1.7)) -@image_comparison(['markevery_log_scales.png'], remove_text=True) +@image_comparison(['markevery_log_scales.png'], remove_text=True, style='_classic_test') def test_markevery_log_scales(): cases = [None, 8, @@ -2001,7 +2006,8 @@ def test_markevery_polar(): plt.plot(theta, r, 'o', ls='-', ms=4, markevery=case) -@image_comparison(['markevery_linear_scales_nans.png'], remove_text=True) +@image_comparison(['markevery_linear_scales_nans.png'], remove_text=True, + style='_classic_test') def test_markevery_linear_scales_nans(): cases = [None, 8, @@ -2027,7 +2033,7 @@ def test_markevery_linear_scales_nans(): plt.plot(x, y, 'o', ls='-', ms=4, markevery=case) -@image_comparison(['marker_edges'], remove_text=True) +@image_comparison(['marker_edges'], remove_text=True, style='_classic_test') def test_marker_edges(): x = np.linspace(0, 1, 10) fig, ax = plt.subplots() @@ -2451,7 +2457,7 @@ def test_pandas_minimal_plot(pd): plt.plot(df, df) -@image_comparison(['hist_log.png'], remove_text=True) +@image_comparison(['hist_log.png'], remove_text=True, style='_classic_test') def test_hist_log(): data0 = np.linspace(0, 1, 200)**3 data = np.concatenate([1 - data0, 1 + data0]) @@ -2500,7 +2506,7 @@ def test_hist_timedelta_raises(): ax.hist(arr_py) -@image_comparison(['hist_bar_empty.png'], remove_text=True) +@image_comparison(['hist_bar_empty.png'], remove_text=True, style='_classic_test') def test_hist_bar_empty(): # From #3886: creating hist from empty dataset raises ValueError ax = plt.gca() @@ -2522,14 +2528,14 @@ def test_hist_float16(): assert rleft[1][0] <= rright[0][0] -@image_comparison(['hist_step_empty.png'], remove_text=True) +@image_comparison(['hist_step_empty.png'], remove_text=True, style='_classic_test') def test_hist_step_empty(): # From #3886: creating hist from empty dataset raises ValueError ax = plt.gca() ax.hist([], histtype='step') -@image_comparison(['hist_step_filled.png'], remove_text=True) +@image_comparison(['hist_step_filled.png'], remove_text=True, style='_classic_test') def test_hist_step_filled(): np.random.seed(0) x = np.random.randn(1000, 3) @@ -2927,7 +2933,7 @@ def test_scatter_plot(self): ax.scatter(data["x"] + 1., data["y"] + 1., c=data["c2"], s=data["s"]) ax.scatter("x", "y", c="c", s="s", data=data) - @image_comparison(['scatter_marker.png'], remove_text=True) + @image_comparison(['scatter_marker.png'], remove_text=True, style='_classic_test') def test_scatter_marker(self): fig, (ax0, ax1, ax2) = plt.subplots(ncols=3) ax0.scatter([3, 4, 2, 6], [2, 5, 2, 3], @@ -2952,7 +2958,7 @@ def test_scatter_marker(self): edgecolors=['k', 'r', 'g', 'b'], marker=verts) - @image_comparison(['scatter_2D.png'], remove_text=True) + @image_comparison(['scatter_2D.png'], remove_text=True, style='_classic_test') def test_scatter_2D(self): x = np.arange(3) y = np.arange(2) @@ -3451,7 +3457,8 @@ def test_stackplot(): ax.set_ylim(0, 70) -@image_comparison(['stackplot_test_baseline.png'], remove_text=True) +@image_comparison(['stackplot_test_baseline.png'], remove_text=True, + style='_classic_test') def test_stackplot_baseline(): np.random.seed(0) @@ -4546,7 +4553,8 @@ def test_errorbar(): ax.set_title("Simplest errorbars, 0.2 in x, 0.4 in y") -@image_comparison(['mixed_errorbar_polar_caps.png'], remove_text=True) +@image_comparison(['mixed_errorbar_polar_caps.png'], remove_text=True, + style='_classic_test') def test_mixed_errorbar_polar_caps(): """ Mix several polar errorbar use cases in a single test figure. @@ -4903,7 +4911,7 @@ def test_hist_offset(): ax.hist(d2, bottom=15) -@image_comparison(['hist_step.png'], remove_text=True) +@image_comparison(['hist_step.png'], remove_text=True, style='_classic_test') def test_hist_step(): # make some data d1 = np.linspace(1, 3, 20) @@ -5091,7 +5099,7 @@ def test_hist_stacked_density(): ax.hist((d1, d2), stacked=True, density=True) -@image_comparison(['hist_step_bottom.png'], remove_text=True) +@image_comparison(['hist_step_bottom.png'], remove_text=True, style='_classic_test') def test_hist_step_bottom(): # make some data d1 = np.linspace(1, 3, 20) @@ -5281,7 +5289,7 @@ def test_hist_labels(): assert bars[0].get_label() == '00' -@image_comparison(['transparent_markers'], remove_text=True) +@image_comparison(['transparent_markers'], remove_text=True, style='_classic_test') def test_transparent_markers(): np.random.seed(0) data = np.random.random(50) @@ -5290,7 +5298,7 @@ def test_transparent_markers(): ax.plot(data, 'D', mfc='none', markersize=100) -@image_comparison(['rgba_markers'], remove_text=True) +@image_comparison(['rgba_markers'], remove_text=True, style='_classic_test') def test_rgba_markers(): fig, axs = plt.subplots(ncols=2) rcolors = [(1, 0, 0, 1), (1, 0, 0, 0.5)] @@ -5307,7 +5315,7 @@ def test_rgba_markers(): ax.axis([-1, 4, 0, 5]) -@image_comparison(['mollweide_grid.png'], remove_text=True) +@image_comparison(['mollweide_grid.png'], remove_text=True, style='_classic_test') def test_mollweide_grid(): # test that both horizontal and vertical gridlines appear on the Mollweide # projection @@ -5360,7 +5368,7 @@ def test_mollweide_inverse_forward_closure(): np.testing.assert_array_almost_equal(xy, xy2, 3) -@image_comparison(['test_alpha'], remove_text=True) +@image_comparison(['test_alpha'], remove_text=True, style='_classic_test') def test_alpha(): np.random.seed(0) data = np.random.random(50) @@ -5390,7 +5398,8 @@ def test_alpha(): markersize=20, lw=10) -@image_comparison(['eventplot.png', 'eventplot.png'], remove_text=True) +@image_comparison(['eventplot.png', 'eventplot.png'], remove_text=True, + style='_classic_test') def test_eventplot(): np.random.seed(0) @@ -5434,7 +5443,8 @@ def test_eventplot(): assert num_collections == num_datasets -@image_comparison(['test_eventplot_defaults.png'], remove_text=True) +@image_comparison(['test_eventplot_defaults.png'], remove_text=True, + style='_classic_test') def test_eventplot_defaults(): """ test that eventplot produces the correct output given the default params @@ -5497,7 +5507,8 @@ def test_eventplot_alpha(): ax.eventplot([0, 2, 4], alpha=[0.5, 0.7]) -@image_comparison(['test_eventplot_problem_kwargs.png'], remove_text=True) +@image_comparison(['test_eventplot_problem_kwargs.png'], remove_text=True, + style='_classic_test') def test_eventplot_problem_kwargs(recwarn): """ test that 'singular' versions of LineCollection props raise an @@ -5557,7 +5568,7 @@ def test_eventplot_units_list(fig_test, fig_ref): ax.eventplot([ts_1, ts_2]) -@image_comparison(['marker_styles.png'], remove_text=True) +@image_comparison(['marker_styles.png'], remove_text=True, style='_classic_test') def test_marker_styles(): fig, ax = plt.subplots() # Since generation of the test image, None was removed but 'none' was @@ -5584,7 +5595,7 @@ def test_markers_fillstyle_rcparams(): ax.plot(x+idx, marker=marker) -@image_comparison(['vertex_markers.png'], remove_text=True) +@image_comparison(['vertex_markers.png'], remove_text=True, style='_classic_test') def test_vertex_markers(): data = list(range(10)) marker_as_tuple = ((-1, -1), (1, -1), (1, 1), (-1, 1)) @@ -5845,7 +5856,7 @@ def test_vlines_hlines_blended_transform(): @image_comparison(['step_linestyle', 'step_linestyle'], remove_text=True, - tol=0.2) + style='_classic_test', tol=0.2) def test_step_linestyle(): # Tolerance caused by reordering of floating-point operations # Remove when regenerating the images @@ -5877,7 +5888,7 @@ def test_step_linestyle(): ax.set_ylim(-1, 7) -@image_comparison(['mixed_collection'], remove_text=True) +@image_comparison(['mixed_collection'], remove_text=True, style='_classic_test') def test_mixed_collection(): # First illustrate basic pyplot interface, using defaults where possible. fig, ax = plt.subplots() @@ -6056,7 +6067,7 @@ def test_specgram_origin_kwarg(): @image_comparison( ["psd_freqs.png", "csd_freqs.png", "psd_noise.png", "csd_noise.png"], - remove_text=True, tol=0.002) + remove_text=True, style='_classic_test', tol=0.002) def test_psd_csd(): n = 10000 Fs = 100. @@ -6097,7 +6108,7 @@ def test_psd_csd(): "magnitude_spectrum_noise_dB.png", "angle_spectrum_noise.png", "phase_spectrum_noise.png"], - remove_text=True) + remove_text=True, style='_classic_test') def test_spectrum(): n = 10000 Fs = 100. @@ -6155,7 +6166,7 @@ def test_twin_remove(fig_test, fig_ref): ax_ref.yaxis.tick_left() -@image_comparison(['twin_spines.png'], remove_text=True, +@image_comparison(['twin_spines.png'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.022) def test_twin_spines(): @@ -6202,7 +6213,7 @@ def make_patch_spines_invisible(ax): @image_comparison(['twin_spines_on_top.png', 'twin_spines_on_top.png'], - remove_text=True) + remove_text=True, style='_classic_test') def test_twin_spines_on_top(): matplotlib.rcParams['axes.linewidth'] = 48.0 matplotlib.rcParams['lines.linewidth'] = 48.0 @@ -7344,7 +7355,7 @@ def test_errorbar_inputs_shotgun(kwargs): eb.remove() -@image_comparison(["dash_offset"], remove_text=True) +@image_comparison(["dash_offset"], remove_text=True, style='_classic_test') def test_dash_offset(): fig, ax = plt.subplots() x = np.linspace(0, 10) @@ -7398,7 +7409,7 @@ def test_title_location_shared(sharex): assert y1 == y2 == 1.0 -@image_comparison(["loglog.png"], remove_text=True, tol=0.02) +@image_comparison(["loglog.png"], remove_text=True, style='_classic_test', tol=0.02) def test_loglog(): fig, ax = plt.subplots() x = np.arange(1, 11) @@ -7740,7 +7751,7 @@ def test_bar_uint8(): assert patch.xy[0] == x -@image_comparison(['axisbelow.png'], remove_text=True) +@image_comparison(['axisbelow.png'], remove_text=True, style='_classic_test') def test_axisbelow(): # Test 'line' setting added in 6287. # Show only grids, not frame or ticks, to make this test @@ -10043,8 +10054,8 @@ def test_boxplot_orientation(fig_test, fig_ref): ax_test.boxplot(all_data, orientation='horizontal') -@image_comparison(["use_colorizer_keyword.png"], - tol=0 if platform.machine() == 'x86_64' else 0.05) +@image_comparison(["use_colorizer_keyword.png"], style='_classic_test', + tol=0 if platform.machine() == 'x86_64' else 0.05) def test_use_colorizer_keyword(): # test using the colorizer keyword np.random.seed(0) diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index 20776af13307..2088ce764b5c 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -21,7 +21,7 @@ from matplotlib.testing._markers import needs_usetex -@image_comparison(['pdf_use14corefonts.pdf']) +@image_comparison(['pdf_use14corefonts.pdf'], style='_classic_test') def test_use14corefonts(): rcParams['pdf.use14corefonts'] = True rcParams['font.family'] = 'sans-serif' @@ -309,7 +309,7 @@ def test_hatching_legend(text_placeholders): fig.legend([a, b, a, b], ["", "", "", ""]) -@image_comparison(['grayscale_alpha.pdf']) +@image_comparison(['grayscale_alpha.pdf'], style='_classic_test') def test_grayscale_alpha(): """Masking images with NaN did not work for grayscale images""" x, y = np.ogrid[-2:2:.1, -2:2:.1] @@ -464,7 +464,7 @@ def test_truetype_conversion(recwarn): @pytest.mark.skipif(not _has_tex_package("heuristica"), reason="LaTeX lacks heuristica package") -@image_comparison(["font-heuristica.pdf"]) +@image_comparison(["font-heuristica.pdf"], style='_classic_test') def test_font_heuristica(): # Heuristica uses the callothersubr operator for some glyphs mpl.rcParams['text.latex.preamble'] = '\n'.join(( @@ -480,7 +480,7 @@ def test_font_heuristica(): @pytest.mark.skipif(not _has_tex_package("DejaVuSans"), reason="LaTeX lacks DejaVuSans package") -@image_comparison(["font-dejavusans.pdf"]) +@image_comparison(["font-dejavusans.pdf"], style='_classic_test') def test_font_dejavusans(): # DejaVuSans uses the seac operator to compose characters with diacritics mpl.rcParams['text.latex.preamble'] = '\n'.join(( @@ -498,7 +498,7 @@ def test_font_dejavusans(): @pytest.mark.skipif(not _has_tex_package("charter"), reason="LaTeX lacks charter package") -@image_comparison(["font-bitstream-charter.pdf"]) +@image_comparison(["font-bitstream-charter.pdf"], style='_classic_test') def test_font_bitstream_charter(): mpl.rcParams['text.latex.preamble'] = '\n'.join(( r'\usepackage{charter}', diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index 6eac82678362..b8d3d106ef09 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -143,7 +143,7 @@ def test_tilde_in_tempfilename(tmp_path): plt.savefig(base_tempdir / 'tex_demo.eps', format="ps") -@image_comparison(["empty.eps"]) +@image_comparison(["empty.eps"], style='_classic_test') def test_transparency(): fig, ax = plt.subplots() ax.set_axis_off() @@ -152,7 +152,7 @@ def test_transparency(): @needs_usetex -@image_comparison(["empty.eps"]) +@image_comparison(["empty.eps"], style='_classic_test') def test_transparency_tex(): mpl.rcParams['text.usetex'] = True fig, ax = plt.subplots() @@ -210,7 +210,7 @@ def test_usetex_preamble(caplog): plt.savefig(io.BytesIO(), format="ps") -@image_comparison(["useafm.eps"]) +@image_comparison(["useafm.eps"], style='_classic_test') def test_useafm(): mpl.rcParams["ps.useafm"] = True fig, ax = plt.subplots() @@ -219,7 +219,7 @@ def test_useafm(): ax.text(.5, .5, "qk") -@image_comparison(["coloredhatcheszerolw.eps"]) +@image_comparison(["coloredhatcheszerolw.eps"], style='_classic_test') def test_colored_hatch_zero_linewidth(): ax = plt.gca() ax.add_patch(Ellipse((0, 0), 1, 1, hatch='/', facecolor='none', @@ -369,7 +369,7 @@ def test_ttc_type42(): horizontalalignment='center', verticalalignment='center') -@image_comparison(["scatter.eps"]) +@image_comparison(["scatter.eps"], style='_classic_test') def test_path_collection(): rng = np.random.default_rng(19680801) xvals = rng.uniform(0, 1, 10) diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py index 6c540ccebd76..ba565eadb01b 100644 --- a/lib/matplotlib/tests/test_backend_svg.py +++ b/lib/matplotlib/tests/test_backend_svg.py @@ -39,13 +39,14 @@ def test_visibility(): parser.Parse(buf) # this will raise ExpatError if the svg is invalid -@image_comparison(['fill_black_with_alpha.svg'], remove_text=True) +@image_comparison(['fill_black_with_alpha.svg'], remove_text=True, + style='_classic_test') def test_fill_black_with_alpha(): fig, ax = plt.subplots() ax.scatter(x=[0, 0.1, 1], y=[0, 0, 0], c='k', alpha=0.1, s=10000) -@image_comparison(['noscale'], remove_text=True) +@image_comparison(['noscale'], remove_text=True, style='_classic_test') def test_noscale(): X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1)) Z = np.sin(Y ** 2) @@ -78,7 +79,7 @@ def test_bold_font_output(): ax.set_title('bold-title', fontweight=600) -@image_comparison(['bold_font_output_with_none_fonttype.svg']) +@image_comparison(['bold_font_output_with_none_fonttype.svg'], style='_classic_test') def test_bold_font_output_with_none_fonttype(): plt.rcParams['svg.fonttype'] = 'none' fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_bbox_tight.py b/lib/matplotlib/tests/test_bbox_tight.py index f6d910a7f208..167e966012ab 100644 --- a/lib/matplotlib/tests/test_bbox_tight.py +++ b/lib/matplotlib/tests/test_bbox_tight.py @@ -90,7 +90,8 @@ def test_bbox_inches_tight_layout_notconstrained(tmp_path): @image_comparison(['bbox_inches_tight_clipping'], - remove_text=True, savefig_kwarg={'bbox_inches': 'tight'}) + remove_text=True, savefig_kwarg={'bbox_inches': 'tight'}, + style='_classic_test') def test_bbox_inches_tight_clipping(): # tests bbox clipping on scatter points, and path clipping on a patch # to generate an appropriately tight bbox diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index dc397ffde93e..294c62785159 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -392,6 +392,7 @@ def test_barb_limits(): @image_comparison(['EllipseCollection_test_image.png'], remove_text=True, + style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.021) def test_EllipseCollection(): # Test basic functionality @@ -514,7 +515,8 @@ def test_scalarmap_change_cmap(fig_test, fig_ref): ax_ref.scatter(x, y, z, c=c, s=40, cmap='viridis') -@image_comparison(['regularpolycollection_rotate.png'], remove_text=True) +@image_comparison(['regularpolycollection_rotate.png'], remove_text=True, + style='_classic_test') def test_regularpolycollection_rotate(): xx, yy = np.mgrid[:10, :10] xy_points = np.transpose([xx.flatten(), yy.flatten()]) @@ -528,7 +530,8 @@ def test_regularpolycollection_rotate(): ax.add_collection(col) -@image_comparison(['regularpolycollection_scale.png'], remove_text=True) +@image_comparison(['regularpolycollection_scale.png'], remove_text=True, + style='_classic_test') def test_regularpolycollection_scale(): # See issue #3860 @@ -647,7 +650,7 @@ def test_linestyle_single_dashes(): plt.draw() -@image_comparison(['size_in_xy.png'], remove_text=True) +@image_comparison(['size_in_xy.png'], remove_text=True, style='_classic_test') def test_size_in_xy(): fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index e3053ca0b231..22c3c818ae92 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -104,7 +104,8 @@ def _colorbar_extension_length(spacing): @image_comparison(['colorbar_extensions_shape_uniform.png', - 'colorbar_extensions_shape_proportional.png']) + 'colorbar_extensions_shape_proportional.png'], + style='_classic_test') def test_colorbar_extension_shape(): """Test rectangular colorbar extensions.""" # Remove this line when this test image is regenerated. @@ -117,7 +118,7 @@ def test_colorbar_extension_shape(): @image_comparison(['colorbar_extensions_uniform.png', 'colorbar_extensions_proportional.png'], - tol=1.0) + style='_classic_test', tol=1.0) def test_colorbar_extension_length(): """Test variable length colorbar extensions.""" # Remove this line when this test image is regenerated. @@ -230,7 +231,7 @@ def test_colorbar_single_ax_panchor_east(constrained): assert ax.get_anchor() == 'E' -@image_comparison(['contour_colorbar.png'], remove_text=True, +@image_comparison(['contour_colorbar.png'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.054) def test_contour_colorbar(): fig, ax = plt.subplots(figsize=(4, 2)) @@ -243,7 +244,7 @@ def test_contour_colorbar(): @image_comparison(['cbar_with_subplots_adjust.png'], remove_text=True, - savefig_kwarg={'dpi': 40}) + savefig_kwarg={'dpi': 40}, style='_classic_test') def test_gridspec_make_colorbar(): plt.figure() data = np.arange(1200).reshape(30, 40) @@ -261,7 +262,7 @@ def test_gridspec_make_colorbar(): @image_comparison(['colorbar_single_scatter.png'], remove_text=True, - savefig_kwarg={'dpi': 40}) + savefig_kwarg={'dpi': 40}, style='_classic_test') def test_colorbar_single_scatter(): # Issue #2642: if a path collection has only one entry, # the norm scaling within the colorbar must ensure a @@ -322,7 +323,8 @@ def test_parentless_mappable(): plt.colorbar(pc) -@image_comparison(['colorbar_closed_patch.png'], remove_text=True) +@image_comparison(['colorbar_closed_patch.png'], remove_text=True, + style='_classic_test') def test_colorbar_closed_patch(): # Remove this line when this test image is regenerated. plt.rcParams['pcolormesh.snap'] = False @@ -1144,7 +1146,7 @@ def test_colorbar_set_formatter_locator(): @image_comparison(['colorbar_extend_alpha.png'], remove_text=True, - savefig_kwarg={'dpi': 40}) + savefig_kwarg={'dpi': 40}, style='_classic_test') def test_colorbar_extend_alpha(): fig, ax = plt.subplots() im = ax.imshow([[0, 1], [2, 3]], alpha=0.3, interpolation="none") diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 808770e1d52c..98b46e08a171 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -844,7 +844,7 @@ def test_cmap_and_norm_from_levels_and_colors(): ax.tick_params(labelleft=False, labelbottom=False) -@image_comparison(['boundarynorm_and_colorbar.png']) +@image_comparison(['boundarynorm_and_colorbar.png'], style='_classic_test') def test_boundarynorm_and_colorbarbase(): # Make a figure and axes with dimensions as desired. fig = plt.figure() @@ -953,7 +953,7 @@ def test_autoscale_masked(): plt.draw() -@image_comparison(['light_source_shading_topo.png']) +@image_comparison(['light_source_shading_topo.png'], style='_classic_test') def test_light_source_topo_surface(): """Shades a DEM using different v.e.'s and blend modes.""" dem = cbook.get_sample_data('jacksboro_fault_dem.npz') @@ -1828,8 +1828,8 @@ def test_LinearSegmentedColormap_from_list_value_color_tuple(): ) -@image_comparison(['test_norm_abc.png'], remove_text=True, - tol=0 if platform.machine() == 'x86_64' else 0.05) +@image_comparison(['test_norm_abc.png'], remove_text=True, style='_classic_test', + tol=0 if platform.machine() == 'x86_64' else 0.05) def test_norm_abc(): class CustomHalfNorm(mcolors.Norm): diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index 98f6de210eab..53921e70046c 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -140,6 +140,7 @@ def test_contour_label_with_disconnected_segments(): @image_comparison(['contour_manual_colors_and_levels.png'], remove_text=True, + style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.018) def test_given_colors_levels_and_extends(): # Remove this line when this test image is regenerated. @@ -319,7 +320,7 @@ def test_clabel_raises_on_filled_contours(): @image_comparison(['contour_corner_mask_False.png', 'contour_corner_mask_True.png'], - remove_text=True, tol=1.88) + remove_text=True, style='_classic_test', tol=1.88) def test_corner_mask(): n = 60 mask_level = 0.95 @@ -495,7 +496,8 @@ def test_label_nonagg(): plt.clabel(plt.contour([[1, 2], [3, 4]])) -@image_comparison(['contour_closed_line_loop.png'], remove_text=True) +@image_comparison(['contour_closed_line_loop.png'], remove_text=True, + style='_classic_test') def test_contour_closed_line_loop(): # github issue 19568. z = [[0, 0, 0], [0, 2, 0], [0, 0, 0], [2, 1, 2]] @@ -519,7 +521,8 @@ def test_quadcontourset_reuse(): assert qcs3._contour_generator == qcs1._contour_generator -@image_comparison(['contour_manual.png'], remove_text=True, tol=0.89) +@image_comparison(['contour_manual.png'], remove_text=True, style='_classic_test', + tol=0.89) def test_contour_manual(): # Manually specifying contour lines/polygons to plot. from matplotlib.contour import ContourSet @@ -544,7 +547,8 @@ def test_contour_manual(): ContourSet(ax, [2], [segs], [kinds], colors='k', linewidths=3) -@image_comparison(['contour_line_start_on_corner_edge.png'], remove_text=True) +@image_comparison(['contour_line_start_on_corner_edge.png'], remove_text=True, + style='_classic_test') def test_contour_line_start_on_corner_edge(): fig, ax = plt.subplots(figsize=(6, 5)) @@ -678,7 +682,8 @@ def test_algorithm_supports_corner_mask(algorithm): plt.contourf(z, algorithm=algorithm, corner_mask=True) -@image_comparison(['contour_all_algorithms.png'], remove_text=True, tol=0.06) +@image_comparison(['contour_all_algorithms.png'], remove_text=True, + style='_classic_test', tol=0.06) def test_all_algorithms(): algorithms = ['mpl2005', 'mpl2014', 'serial', 'threaded'] diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index 0e318cab0d4f..fbfb2515f42e 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -388,8 +388,8 @@ def test_remove_suptitle_supxlabel_supylabel(): # only test png and svg. The PDF output appears correct, # but Ghostscript does not preserve the background color. extensions=['png', 'svg'], - savefig_kwarg={'facecolor': (0, 1, 0.4), - 'edgecolor': 'none'}) + savefig_kwarg={'facecolor': (0, 1, 0.4), 'edgecolor': 'none'}, + style='_classic_test') def test_alpha(): # We want an image which has a background color and an alpha of 0.4. fig = plt.figure(figsize=[2, 1]) diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 78dacfd72907..e193e0d9fd3e 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -36,7 +36,7 @@ def inverted(self): return NonAffineIdentityTransform() -@image_comparison(['interp_alpha.png'], remove_text=True) +@image_comparison(['interp_alpha.png'], remove_text=True, style='_classic_test') def test_alpha_interp(): """Test the interpolation of the alpha channel on RGBA images""" fig, (axl, axr) = plt.subplots(1, 2) @@ -68,7 +68,7 @@ def test_interp_nearest_vs_none(): @pytest.mark.parametrize('suppressComposite', [False, True]) -@image_comparison(['figimage'], extensions=['png', 'pdf']) +@image_comparison(['figimage'], extensions=['png', 'pdf'], style='_classic_test') def test_figimage(suppressComposite): fig = plt.figure(figsize=(2, 2), dpi=100) fig.suppressComposite = suppressComposite @@ -278,7 +278,7 @@ def test_imsave_pil_kwargs_tiff(): assert tags["ImageDescription"] == "test image" -@image_comparison(['image_alpha'], remove_text=True) +@image_comparison(['image_alpha'], remove_text=True, style='_classic_test') def test_image_alpha(): np.random.seed(0) Z = np.random.rand(6, 6) @@ -553,7 +553,7 @@ def test_imshow_10_10_5(): ax.imshow(arr) -@image_comparison(['no_interpolation_origin'], remove_text=True) +@image_comparison(['no_interpolation_origin'], remove_text=True, style='_classic_test') def test_no_interpolation_origin(): fig, axs = plt.subplots(2) axs[0].imshow(np.arange(100).reshape((2, 50)), origin="lower", @@ -561,7 +561,8 @@ def test_no_interpolation_origin(): axs[1].imshow(np.arange(100).reshape((2, 50)), interpolation='none') -@image_comparison(['image_shift'], remove_text=True, extensions=['pdf', 'svg']) +@image_comparison(['image_shift'], extensions=['pdf', 'svg'], remove_text=True, + style='_classic_test') def test_image_shift(): imgData = [[1 / x + 1 / y for x in range(1, 100)] for y in range(1, 100)] tMin = 734717.945208 @@ -612,7 +613,8 @@ def test_image_composite_background(): ax.set_xlim(0, 12) -@image_comparison(['image_composite_alpha'], remove_text=True, tol=0.07) +@image_comparison(['image_composite_alpha'], remove_text=True, style='_classic_test', + tol=0.07) def test_image_composite_alpha(): """ Tests that the alpha value is recognized and correctly applied in the @@ -879,7 +881,7 @@ def test_load_from_url(): plt.imread(file) -@image_comparison(['log_scale_image'], remove_text=True) +@image_comparison(['log_scale_image'], remove_text=True, style='_classic_test') def test_log_scale_image(): Z = np.zeros((10, 10)) Z[::2] = 1 @@ -890,7 +892,7 @@ def test_log_scale_image(): ax.set(yscale='log') -@image_comparison(['rotate_image'], remove_text=True) +@image_comparison(['rotate_image'], remove_text=True, style='_classic_test') def test_rotate_image(): delta = 0.25 x = y = np.arange(-3.0, 3.0, delta) @@ -950,7 +952,8 @@ def test_image_preserve_size2(): np.identity(n, bool)[::-1]) -@image_comparison(['mask_image_over_under.png'], remove_text=True, tol=1.0) +@image_comparison(['mask_image_over_under.png'], remove_text=True, + style='_classic_test', tol=1.0) def test_mask_image_over_under(): delta = 0.025 @@ -982,7 +985,7 @@ def test_mask_image_over_under(): orientation='horizontal', ax=ax2, aspect=10) -@image_comparison(['mask_image'], remove_text=True) +@image_comparison(['mask_image'], remove_text=True, style='_classic_test') def test_mask_image(): # Test mask image two ways: Using nans and using a masked array. @@ -1008,7 +1011,7 @@ def test_mask_image_all(): fig.canvas.draw_idle() # would emit a warning -@image_comparison(['imshow_endianess.png'], remove_text=True) +@image_comparison(['imshow_endianess.png'], remove_text=True, style='_classic_test') def test_imshow_endianess(): x = np.arange(10) X, Y = np.meshgrid(x, x) @@ -1884,7 +1887,7 @@ def test_interpolation_stage_rgba_respects_alpha_param(fig_test, fig_ref, intp_s ) -@image_comparison(['nn_pixel_alignment.png']) +@image_comparison(['nn_pixel_alignment.png'], style='_classic_test') def test_nn_pixel_alignment(nonaffine_identity): fig, axs = plt.subplots(2, 3) @@ -1965,7 +1968,7 @@ def test_alignment_half_display_pixels(nonaffine_identity): ax.spines[spine].set_linestyle((0, (5, 10))) -@image_comparison(['image_bounds_handling.png'], tol=0.006) +@image_comparison(['image_bounds_handling.png'], style='_classic_test', tol=0.006) def test_image_bounds_handling(nonaffine_identity): # TODO: The second and third panels in the bottom row show that the handling of # image bounds is bugged for non-affine transforms and non-nearest-neighbor @@ -1996,7 +1999,7 @@ def test_image_bounds_handling(nonaffine_identity): axs[i, j].add_artist(box) -@image_comparison(['rgba_clean_edges.png'], tol=0.003) +@image_comparison(['rgba_clean_edges.png'], style='_classic_test', tol=0.003) def test_rgba_clean_edges(): np.random.seed(19680801+9) # same as in test_upsampling() data = np.random.rand(8, 8) @@ -2026,7 +2029,7 @@ def test_rgba_clean_edges(): axs[i].set_ylim(-2.5, 9.5) -@image_comparison(['affine_fill_to_edges.png']) +@image_comparison(['affine_fill_to_edges.png'], style='_classic_test') def test_affine_fill_to_edges(): # The two rows show the two settings of origin # The three columns show the original and the two mirror flips diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index e2a63bbf962b..33a06e326d4a 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -51,7 +51,7 @@ def test_invalid_line_data(): line.set_ydata(0) -@image_comparison(['line_dashes'], remove_text=True, tol=0.003) +@image_comparison(['line_dashes'], remove_text=True, style='_classic_test', tol=0.003) def test_line_dashes(): # Tolerance introduced after reordering of floating-point operations # Remove when regenerating the images @@ -99,7 +99,7 @@ def test_zero_linewidth_dashed_uses_solid_gc_dashes(): fig.draw_without_rendering() -@image_comparison(['drawstyle_variants.png'], remove_text=True, +@image_comparison(['drawstyle_variants.png'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.03) def test_drawstyle_variants(): fig, axs = plt.subplots(6) @@ -151,7 +151,7 @@ def test_set_line_coll_dash_image(): ax.contour(np.random.randn(20, 30), linestyles=[(0, (3, 3))]) -@image_comparison(['marker_fill_styles.png'], remove_text=True) +@image_comparison(['marker_fill_styles.png'], remove_text=True, style='_classic_test') def test_marker_fill_styles(): colors = itertools.cycle([[0, 0, 1], 'g', '#ff0000', 'c', 'm', 'y', np.array([0, 0, 0])]) diff --git a/lib/matplotlib/tests/test_multivariate_colormaps.py b/lib/matplotlib/tests/test_multivariate_colormaps.py index 592058212a24..73a2a2e2227c 100644 --- a/lib/matplotlib/tests/test_multivariate_colormaps.py +++ b/lib/matplotlib/tests/test_multivariate_colormaps.py @@ -11,7 +11,7 @@ import base64 -@image_comparison(["bivariate_cmap_shapes.png"]) +@image_comparison(["bivariate_cmap_shapes.png"], style='_classic_test') def test_bivariate_cmap_shapes(): x_0 = np.repeat(np.linspace(-0.1, 1.1, 10, dtype='float32')[None, :], 10, axis=0) x_1 = x_0.T @@ -63,7 +63,7 @@ def test_multivar_creation(): cmap = mpl.colors.MultivarColormap((blues), 'sRGB_sub') -@image_comparison(["multivar_alpha_mixing.png"]) +@image_comparison(["multivar_alpha_mixing.png"], style='_classic_test') def test_multivar_alpha_mixing(): # test creation of a custom colormap using 'rainbow' # and a colormap that goes from alpha = 1 to alpha = 0 diff --git a/lib/matplotlib/tests/test_offsetbox.py b/lib/matplotlib/tests/test_offsetbox.py index f126b1cbb466..4ea6688d8651 100644 --- a/lib/matplotlib/tests/test_offsetbox.py +++ b/lib/matplotlib/tests/test_offsetbox.py @@ -16,7 +16,7 @@ OffsetBox, OffsetImage, PaddedBox, TextArea, VPacker, _get_packed_offsets) -@image_comparison(['offsetbox_clipping'], remove_text=True) +@image_comparison(['offsetbox_clipping'], remove_text=True, style='_classic_test') def test_offsetbox_clipping(): # - create a plot # - put an AnchoredOffsetbox with a child DrawingArea diff --git a/lib/matplotlib/tests/test_patches.py b/lib/matplotlib/tests/test_patches.py index 12a12cf3e90d..3a79bce643ea 100644 --- a/lib/matplotlib/tests/test_patches.py +++ b/lib/matplotlib/tests/test_patches.py @@ -269,7 +269,7 @@ def test_clip_to_bbox(): ax.add_patch(result_patch) -@image_comparison(['patch_alpha_coloring'], remove_text=True) +@image_comparison(['patch_alpha_coloring'], remove_text=True, style='_classic_test') def test_patch_alpha_coloring(): """ Test checks that the patch and collection are rendered with the specified @@ -300,7 +300,7 @@ def test_patch_alpha_coloring(): ax.set_ylim(-1, 2) -@image_comparison(['patch_alpha_override'], remove_text=True) +@image_comparison(['patch_alpha_override'], remove_text=True, style='_classic_test') def test_patch_alpha_override(): #: Test checks that specifying an alpha attribute for a patch or #: collection will override any alpha component of the facecolor @@ -340,7 +340,7 @@ def test_patch_color_none(): assert c.get_facecolor()[0] == 0 -@image_comparison(['patch_custom_linestyle'], remove_text=True) +@image_comparison(['patch_custom_linestyle'], remove_text=True, style='_classic_test') def test_patch_custom_linestyle(): #: A test to check that patches and collections accept custom dash #: patterns as linestyle and that they display correctly. @@ -437,7 +437,7 @@ def test_wedge_movement(): assert getattr(w, attr) == new_v -@image_comparison(['wedge_range'], remove_text=True, +@image_comparison(['wedge_range'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.009) def test_wedge_range(): ax = plt.axes() diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index a61f01c0d48a..fd41a4ae6a96 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -189,7 +189,7 @@ def test_arrow_contains_point(): ax.scatter(x, y, s=5, c="r") -@image_comparison(['path_clipping.svg'], remove_text=True) +@image_comparison(['path_clipping.svg'], remove_text=True, style='_classic_test') def test_path_clipping(): fig = plt.figure(figsize=(6.0, 6.2)) @@ -242,7 +242,7 @@ def test_make_compound_path_stops(): assert np.sum(compound_path.codes == Path.STOP) == 0 -@image_comparison(['xkcd.png'], remove_text=True) +@image_comparison(['xkcd.png'], remove_text=True, style='_classic_test') def test_xkcd(): np.random.seed(0) @@ -254,7 +254,7 @@ def test_xkcd(): ax.plot(x, y) -@image_comparison(['xkcd_marker.png'], remove_text=True) +@image_comparison(['xkcd_marker.png'], remove_text=True, style='_classic_test') def test_xkcd_marker(): np.random.seed(0) @@ -270,7 +270,7 @@ def test_xkcd_marker(): ax.plot(x, y3, '^', ms=10) -@image_comparison(['marker_paths.pdf'], remove_text=True) +@image_comparison(['marker_paths.pdf'], remove_text=True, style='_classic_test') def test_marker_paths_pdf(): N = 7 diff --git a/lib/matplotlib/tests/test_quiver.py b/lib/matplotlib/tests/test_quiver.py index 4784a7e4dc42..fc0214f066ee 100644 --- a/lib/matplotlib/tests/test_quiver.py +++ b/lib/matplotlib/tests/test_quiver.py @@ -123,7 +123,8 @@ def test_quiver_with_key(): fontproperties={'weight': 'bold', 'size': 'large'}) -@image_comparison(['quiver_single_test_image.png'], remove_text=True) +@image_comparison(['quiver_single_test_image.png'], remove_text=True, + style='_classic_test') def test_quiver_single(): fig, ax = plt.subplots() ax.margins(0.1) @@ -153,7 +154,7 @@ def test_quiver_key_pivot(): ax.quiverkey(q, 0, 0.5, 1, 'W', labelpos='W') -@image_comparison(['quiver_key_xy.png'], remove_text=True) +@image_comparison(['quiver_key_xy.png'], remove_text=True, style='_classic_test') def test_quiver_key_xy(): # With scale_units='xy', ensure quiverkey still matches its quiver. # Note that the quiver and quiverkey lengths depend on the axes aspect @@ -177,7 +178,7 @@ def test_quiver_key_xy(): ax.quiverkey(q, X=x, Y=0.8, U=1, angle=angle, label='', color='b') -@image_comparison(['barbs_test_image.png'], remove_text=True) +@image_comparison(['barbs_test_image.png'], remove_text=True, style='_classic_test') def test_barbs(): x = np.linspace(-5, 5, 5) X, Y = np.meshgrid(x, x) @@ -188,7 +189,8 @@ def test_barbs(): cmap='viridis') -@image_comparison(['barbs_pivot_test_image.png'], remove_text=True) +@image_comparison(['barbs_pivot_test_image.png'], remove_text=True, + style='_classic_test') def test_barbs_pivot(): x = np.linspace(-5, 5, 5) X, Y = np.meshgrid(x, x) @@ -199,7 +201,7 @@ def test_barbs_pivot(): ax.scatter(X, Y, s=49, c='black') -@image_comparison(['barbs_test_flip.png'], remove_text=True) +@image_comparison(['barbs_test_flip.png'], remove_text=True, style='_classic_test') def test_barbs_flip(): """Test barbs with an array for flip_barb.""" x = np.linspace(-5, 5, 5) @@ -244,7 +246,7 @@ def test_angles_and_scale(): ax.quiver(X, Y, U, V, angles=phi, scale_units='xy') -@image_comparison(['quiver_xy.png'], remove_text=True) +@image_comparison(['quiver_xy.png'], remove_text=True, style='_classic_test') def test_quiver_xy(): # simple arrow pointing from SW to NE fig, ax = plt.subplots(subplot_kw=dict(aspect='equal')) diff --git a/lib/matplotlib/tests/test_scale.py b/lib/matplotlib/tests/test_scale.py index 9f882103967e..95601ce97b65 100644 --- a/lib/matplotlib/tests/test_scale.py +++ b/lib/matplotlib/tests/test_scale.py @@ -59,7 +59,7 @@ def test_symlog_mask_nan(): assert type(out) is type(x) -@image_comparison(['logit_scales.png'], remove_text=True) +@image_comparison(['logit_scales.png'], remove_text=True, style='_classic_test') def test_logit_scales(): fig, ax = plt.subplots() @@ -102,7 +102,7 @@ def test_logscale_subs(): fig.canvas.draw() -@image_comparison(['logscale_mask.png'], remove_text=True) +@image_comparison(['logscale_mask.png'], remove_text=True, style='_classic_test') def test_logscale_mask(): # Check that zero values are masked correctly on log scales. # See github issue 8045 diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py index 6b2e5b4cd301..ab7c777810a0 100644 --- a/lib/matplotlib/tests/test_simplification.py +++ b/lib/matplotlib/tests/test_simplification.py @@ -18,7 +18,7 @@ # NOTE: All of these tests assume that path.simplify is set to True # (the default) -@image_comparison(['clipping'], remove_text=True) +@image_comparison(['clipping'], remove_text=True, style='_classic_test') def test_clipping(): t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) @@ -28,7 +28,7 @@ def test_clipping(): ax.set_ylim(-0.20, -0.28) -@image_comparison(['overflow'], remove_text=True, +@image_comparison(['overflow'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.007) def test_overflow(): x = np.array([1.0, 2.0, 3.0, 2.0e5]) @@ -39,7 +39,7 @@ def test_overflow(): ax.set_xlim(2, 6) -@image_comparison(['clipping_diamond'], remove_text=True) +@image_comparison(['clipping_diamond'], remove_text=True, style='_classic_test') def test_diamond(): x = np.array([0.0, 1.0, 0.0, -1.0, 0.0]) y = np.array([1.0, 0.0, -1.0, 0.0, 1.0]) @@ -233,7 +233,8 @@ def test_sine_plus_noise(): assert simplified.vertices.size == 25240 -@image_comparison(['simplify_curve'], remove_text=True, tol=0.017) +@image_comparison(['simplify_curve'], remove_text=True, style='_classic_test', + tol=0.017) def test_simplify_curve(): pp1 = patches.PathPatch( Path([(0, 0), (1, 0), (1, 1), (np.nan, 1), (0, 0), (2, 0), (2, 2), @@ -397,7 +398,7 @@ def test_closed_path_clipping(fig_test, fig_ref): fig_ref.add_artist(patches.PathPatch(path, facecolor='none')) -@image_comparison(['hatch_simplify'], remove_text=True) +@image_comparison(['hatch_simplify'], remove_text=True, style='_classic_test') def test_hatch(): fig, ax = plt.subplots() ax.add_patch(plt.Rectangle((0, 0), 1, 1, fill=False, hatch="/")) @@ -405,7 +406,7 @@ def test_hatch(): ax.set_ylim(0.45, 0.55) -@image_comparison(['fft_peaks'], remove_text=True) +@image_comparison(['fft_peaks'], remove_text=True, style='_classic_test') def test_fft_peaks(): fig, ax = plt.subplots() t = np.arange(65536) @@ -467,7 +468,7 @@ def test_throw_rendering_complexity_exceeded(high_memory): fig.savefig(io.BytesIO()) -@image_comparison(['clipper_edge'], remove_text=True) +@image_comparison(['clipper_edge'], remove_text=True, style='_classic_test') def test_clipper(): dat = (0, 1, 0, 2, 0, 3, 0, 4, 0, 5) fig = plt.figure(figsize=(2, 1)) @@ -483,7 +484,7 @@ def test_clipper(): ax.set_xlim(5, 9) -@image_comparison(['para_equal_perp'], remove_text=True) +@image_comparison(['para_equal_perp'], remove_text=True, style='_classic_test') def test_para_equal_perp(): x = np.array([0, 1, 2, 1, 0, -1, 0, 1] + [1] * 128) y = np.array([1, 1, 2, 1, 0, -1, 0, 0] + [0] * 128) diff --git a/lib/matplotlib/tests/test_skew.py b/lib/matplotlib/tests/test_skew.py index 125ecd7ff606..3ef7e905d42f 100644 --- a/lib/matplotlib/tests/test_skew.py +++ b/lib/matplotlib/tests/test_skew.py @@ -133,7 +133,7 @@ def upper_xlim(self): register_projection(SkewXAxes) -@image_comparison(['skew_axes.png'], remove_text=True) +@image_comparison(['skew_axes.png'], remove_text=True, style='_classic_test') def test_set_line_coll_dash_image(): fig = plt.figure() ax = fig.add_subplot(1, 1, 1, projection='skewx') @@ -145,7 +145,7 @@ def test_set_line_coll_dash_image(): ax.axvline(0, color='b') -@image_comparison(['skew_rects.png'], remove_text=True, +@image_comparison(['skew_rects.png'], remove_text=True, style='_classic_test', tol=0 if platform.machine() == 'x86_64' else 0.009) def test_skew_rectangle(): diff --git a/lib/matplotlib/tests/test_spines.py b/lib/matplotlib/tests/test_spines.py index 4945c53d904d..b652b1f78867 100644 --- a/lib/matplotlib/tests/test_spines.py +++ b/lib/matplotlib/tests/test_spines.py @@ -106,7 +106,7 @@ def test_spine_nonlinear_data_positions(fig_test, fig_ref): ax.tick_params(axis="y", labelleft=False, left=False, right=True) -@image_comparison(['spines_capstyle.png']) +@image_comparison(['spines_capstyle.png'], style='_classic_test') def test_spines_capstyle(): # issue 2542 plt.rc('axes', linewidth=20) @@ -144,7 +144,7 @@ def test_label_without_ticks(): "X-Axis label not below the spine" -@image_comparison(['black_axes.png']) +@image_comparison(['black_axes.png'], style='_classic_test') def test_spines_black_axes(): # GitHub #18804 plt.rcParams["savefig.pad_inches"] = 0 diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index dad82f6af4fb..70715696df30 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -642,7 +642,7 @@ def test_single_artist_usenotex(fmt): fig.savefig(io.BytesIO(), format=fmt) -@image_comparison(['text_as_path_opacity.svg']) +@image_comparison(['text_as_path_opacity.svg'], style='_classic_test') def test_text_as_path_opacity(): plt.figure() plt.gca().set_axis_off() @@ -651,7 +651,7 @@ def test_text_as_path_opacity(): plt.text(0.25, 0.75, 'x', alpha=0.5, color=(0, 0, 0, 1)) -@image_comparison(['text_as_text_opacity.svg']) +@image_comparison(['text_as_text_opacity.svg'], style='_classic_test') def test_text_as_text_opacity(): mpl.rcParams['svg.fonttype'] = 'none' plt.figure() diff --git a/lib/matplotlib/tests/test_triangulation.py b/lib/matplotlib/tests/test_triangulation.py index c9187915b5a2..0293423e06b0 100644 --- a/lib/matplotlib/tests/test_triangulation.py +++ b/lib/matplotlib/tests/test_triangulation.py @@ -865,7 +865,8 @@ def z(x, y): matest.assert_array_almost_equal(interpz, interp_z0[interp_key]) -@image_comparison(['tri_smooth_contouring.png'], remove_text=True, tol=0.072) +@image_comparison(['tri_smooth_contouring.png'], remove_text=True, + style='_classic_test', tol=0.072) def test_tri_smooth_contouring(): # Image comparison based on example tricontour_smooth_user. n_angles = 20 @@ -904,7 +905,8 @@ def z(x, y): plt.tricontour(tri_refi, z_test_refi, levels=levels, colors="black") -@image_comparison(['tri_smooth_gradient.png'], remove_text=True, tol=0.092) +@image_comparison(['tri_smooth_gradient.png'], remove_text=True, style='_classic_test', + tol=0.092) def test_tri_smooth_gradient(): # Image comparison based on example trigradient_demo.