Skip to content

Commit

Permalink
Delay warning for deprecated parameter 'vert' of box and violin on 3.10
Browse files Browse the repository at this point in the history
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 matplotlib#29155 being the accompanying version to edit the deprecation on main.

Reinstate warning as a pending warning

STY: fits on one line
  • Loading branch information
ksunden committed Nov 22, 2024
1 parent 82f7254 commit f356da1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 13 additions & 7 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit f356da1

Please sign in to comment.