From f356da148feeeee30ba4dc388d569ac860e9f8d9 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Tue, 19 Nov 2024 17:15:23 -0600 Subject: [PATCH] Delay warning for deprecated parameter 'vert' of box and violin on 3.10 The new parameter, 'orientation', was only added in the current release, so downstream wanting to avoid warnings would require version gates. Therefore delaying by at least one release to ease the transition. This was motivated by Pandas failing tests on this warning. This portion is made direct to v3.10.x with #29155 being the accompanying version to edit the deprecation on main. Reinstate warning as a pending warning STY: fits on one line --- lib/matplotlib/axes/_axes.py | 20 +++++++++++++------- lib/matplotlib/tests/test_axes.py | 4 +++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index f6a4ebfdc7c6..af5173d2503e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3875,9 +3875,11 @@ def boxplot(self, x, notch=None, sym=None, vert=None, control is provided by the *flierprops* parameter. vert : bool, optional - .. deprecated:: 3.10 + .. deprecated:: 3.11 Use *orientation* instead. + This is a pending deprecation for 3.10, with full deprecation + in 3.11 and removal in 3.13. If this is given during the deprecation period, it overrides the *orientation* parameter. @@ -4222,9 +4224,11 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=None, The default is ``0.5*(width of the box)``, see *widths*. vert : bool, optional - .. deprecated:: 3.10 + .. deprecated:: 3.11 Use *orientation* instead. + This is a pending deprecation for 3.10, with full deprecation + in 3.11 and removal in 3.13. If this is given during the deprecation period, it overrides the *orientation* parameter. @@ -4361,9 +4365,10 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True): vert = mpl.rcParams['boxplot.vertical'] else: _api.warn_deprecated( - "3.10", + "3.11", name="vert: bool", - alternative="orientation: {'vertical', 'horizontal'}" + alternative="orientation: {'vertical', 'horizontal'}", + pending=True, ) if vert is False: orientation = 'horizontal' @@ -8642,10 +8647,11 @@ def violin(self, vpstats, positions=None, vert=None, # vert takes precedence. if vert is not None: _api.warn_deprecated( - "3.10", + "3.11", name="vert: bool", - alternative="orientation: {'vertical', 'horizontal'}" - ) + alternative="orientation: {'vertical', 'horizontal'}", + pending=True, + ) orientation = 'vertical' if vert else 'horizontal' _api.check_in_list(['horizontal', 'vertical'], orientation=orientation) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 6fe57a3e0d03..ee6f715c3ccd 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -9315,7 +9315,9 @@ def test_violinplot_orientation(fig_test, fig_ref): # Compare images between a figure that # uses vert and one that uses orientation. ax_ref = fig_ref.subplots() - ax_ref.violinplot(all_data, vert=False) + + with pytest.warns(PendingDeprecationWarning, match='vert: bool'): + ax_ref.violinplot(all_data, vert=False) ax_test = fig_test.subplots() ax_test.violinplot(all_data, orientation='horizontal')