Skip to content

Commit 369581e

Browse files
committed
Address other failures
1 parent 7dbf965 commit 369581e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

pandas/plotting/_matplotlib/boxplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import pandas as pd
2222
import pandas.core.common as com
23+
from pandas.util.version import Version
2324

2425
from pandas.io.formats.printing import pprint_thing
2526
from pandas.plotting._matplotlib.core import (
@@ -54,7 +55,8 @@ def _set_ticklabels(ax: Axes, labels: list[str], is_vertical: bool, **kwargs) ->
5455
ticks = ax.get_xticks() if is_vertical else ax.get_yticks()
5556
if len(ticks) != len(labels):
5657
i, remainder = divmod(len(ticks), len(labels))
57-
assert remainder == 0, remainder
58+
if Version(mpl.__version__) < Version("3.10"):
59+
assert remainder == 0, remainder
5860
labels *= i
5961
if is_vertical:
6062
ax.set_xticklabels(labels, **kwargs)

pandas/tests/plotting/frame/test_frame.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ def test_boxplot_vertical(self, hist_df):
10871087
assert len(ax.lines) == 7 * len(numeric_cols)
10881088

10891089
@pytest.mark.filterwarnings("ignore:Attempt:UserWarning")
1090+
@pytest.mark.filterwarnings("ignore:set_ticklabels:UserWarning")
10901091
def test_boxplot_vertical_subplots(self, hist_df):
10911092
df = hist_df
10921093
numeric_cols = df._get_numeric_data().columns

pandas/tests/plotting/test_boxplot_method.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test cases for .boxplot method"""
22

3+
from __future__ import annotations
4+
35
import itertools
46
import string
57

@@ -37,7 +39,7 @@ def _check_ax_limits(col, ax):
3739

3840

3941
if Version(mpl.__version__) < Version("3.10"):
40-
verts = [{"vert": False}, {"vert": True}]
42+
verts: list[dict[str, bool | str]] = [{"vert": False}, {"vert": True}]
4143
else:
4244
verts = [{"orientation": "horizontal"}, {"orientation": "vertical"}]
4345

@@ -337,6 +339,7 @@ def test_plot_xlabel_ylabel(self, vert):
337339
assert ax.get_xlabel() == xlabel
338340
assert ax.get_ylabel() == ylabel
339341

342+
@pytest.mark.filterwarnings("ignore:set_ticklabels:UserWarning")
340343
def test_plot_box(self, vert):
341344
# GH 54941
342345
rng = np.random.default_rng(2)
@@ -378,7 +381,6 @@ def test_boxplot_group_xlabel_ylabel(self, vert):
378381
assert subplot.get_xlabel() == xlabel
379382
assert subplot.get_ylabel() == ylabel
380383

381-
@pytest.mark.parametrize("vert", [True, False])
382384
def test_boxplot_group_no_xlabel_ylabel(self, vert):
383385
df = DataFrame(
384386
{
@@ -387,9 +389,13 @@ def test_boxplot_group_no_xlabel_ylabel(self, vert):
387389
"group": np.random.default_rng(2).choice(["group1", "group2"], 10),
388390
}
389391
)
390-
ax = df.boxplot(by="group", vert=vert)
392+
ax = df.boxplot(by="group", **vert)
391393
for subplot in ax:
392-
target_label = subplot.get_xlabel() if vert else subplot.get_ylabel()
394+
target_label = (
395+
subplot.get_xlabel()
396+
if vert == {"vert": True} or vert == {"orientation": "vertical"}
397+
else subplot.get_ylabel()
398+
)
393399
assert target_label == pprint_thing(["group"])
394400

395401

0 commit comments

Comments
 (0)