Skip to content

Commit a6ebdaf

Browse files
GH1147 Drop version restriction on matplotlib and prevent test to write to root folder (#1148)
* Gh1147 Drop version restriction on matplotlib and prevent test to write to root folder * Gh1147 Drop version restriction on matplotlib and prevent test to write to root folder * GH1147 PR Feedback
1 parent 6db30fc commit a6ebdaf

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

pyproject.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pyright = ">=1.1.396"
4343
poethepoet = ">=0.16.5"
4444
loguru = ">=0.6.0"
4545
typing-extensions = ">=4.4.0"
46-
matplotlib = ">=3.5.1,<3.9.0" # TODO https://github.com/pandas-dev/pandas/issues/58851
46+
matplotlib = ">=3.6.3"
4747
pre-commit = ">=2.19.0"
4848
black = ">=23.3.0"
4949
isort = ">=5.12.0"
@@ -230,8 +230,6 @@ ignore-words-list = "indext, mose, sav, ser"
230230
filterwarnings = [
231231
# treat warnings as errors
232232
"error",
233-
# until there is a new dateutil release: github.com/dateutil/dateutil/pull/1285
234-
"ignore:datetime.datetime.utc:DeprecationWarning",
235233
]
236234

237235
# Next line needed to avoid poetry complaint

tests/test_frame.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3996,8 +3996,10 @@ def test_hashable_args() -> None:
39963996
df.columns = ["test"] # type: ignore[assignment]
39973997

39983998
testDict = {"test": 1}
3999-
df.to_string("test", col_space=testDict)
4000-
df.to_string("test", col_space={"test": 1})
3999+
4000+
with ensure_clean() as path:
4001+
df.to_string(path, col_space=testDict)
4002+
df.to_string(path, col_space={"test": 1})
40014003

40024004

40034005
# GH 906

tests/test_plotting.py

+59-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
import pytest
1717
from typing_extensions import assert_type
1818

19-
from tests import check
19+
from tests import (
20+
PD_LTE_22,
21+
check,
22+
)
2023

2124
from pandas.plotting import (
2225
deregister_matplotlib_converters,
@@ -575,7 +578,10 @@ def test_plot_keywords(close_figures):
575578

576579
df = pd.DataFrame(np.random.rand(10, 5), columns=["A", "B", "C", "D", "E"])
577580
check(
578-
assert_type(df.plot(kind="box", vert=False, positions=[1, 4, 5, 6, 8]), Axes),
581+
assert_type(
582+
df.plot(kind="box", orientation="vertical", positions=[1, 4, 5, 6, 8]),
583+
Axes,
584+
),
579585
Axes,
580586
)
581587

@@ -602,17 +608,67 @@ def test_grouped_dataframe_boxplot(close_figures):
602608
check(assert_type(grouped.boxplot(), Series), Series)
603609
check(assert_type(grouped.boxplot(subplots=True), Series), Series)
604610

611+
# a single plot
612+
if not PD_LTE_22:
613+
check(
614+
assert_type(
615+
grouped.boxplot(
616+
subplots=False,
617+
rot=45,
618+
fontsize=12,
619+
figsize=(8, 10),
620+
orientation="horizontal",
621+
),
622+
Axes,
623+
),
624+
Axes,
625+
)
626+
627+
628+
def test_grouped_dataframe_boxplot_single(close_figures):
629+
"""
630+
Test with pandas 2.2.3 separated to make it pass.
631+
632+
With pandas 2.2.3 the passing of certain keywords is broken so this test
633+
is put separately to make sure that we have no Axes already created.
634+
It will fail with `orientation="horizontal"`.
635+
"""
636+
tuples = [t for t in itertools.product(range(10), range(2))]
637+
index = pd.MultiIndex.from_tuples(tuples, names=["lvl0", "lvl1"])
638+
df = pd.DataFrame(
639+
data=np.random.randn(len(index), 2), columns=["A", "B"], index=index
640+
)
641+
grouped = df.groupby(level="lvl1")
642+
605643
# a single plot
606644
check(
607645
assert_type(
608646
grouped.boxplot(
609-
subplots=False, rot=45, fontsize=12, figsize=(8, 10), vert=False
647+
subplots=False,
648+
rot=45,
649+
fontsize=12,
650+
figsize=(8, 10),
610651
),
611652
Axes,
612653
),
613654
Axes,
614655
)
615656

657+
if not PD_LTE_22:
658+
check(
659+
assert_type(
660+
grouped.boxplot(
661+
subplots=False,
662+
rot=45,
663+
fontsize=12,
664+
figsize=(8, 10),
665+
orientation="horizontal",
666+
),
667+
Axes,
668+
),
669+
Axes,
670+
)
671+
616672
# not a literal bool
617673
check(assert_type(grouped.boxplot(subplots=bool(0.5)), Union[Axes, Series]), Series)
618674

0 commit comments

Comments
 (0)