Skip to content

Pending warning for deprecated parameter 'vert' of box and violin on 3.10 #29159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected 3.10 here („pending depreciation in 3.10“) but am not sure what the message looks like („deprecated in 3.11“) would also be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number actually does not appear in the Pending deprecation, apparently:

PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.

Personally I think this is fine, and leaving the intended deprecation version in source reduces change when actually deprecating (though in this case, it is already fully deprecated on main, so that much doesn't really matter)

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
Loading