Skip to content

GH1089 Fix pandas nightly with new warnings on copy #1152

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 9 commits into from
Mar 13, 2025
10 changes: 8 additions & 2 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3996,7 +3996,6 @@ def test_hashable_args() -> None:
df.columns = ["test"] # type: ignore[assignment]

testDict = {"test": 1}

with ensure_clean() as path:
df.to_string(path, col_space=testDict)
df.to_string(path, col_space={"test": 1})
Expand All @@ -4011,7 +4010,14 @@ def test_transpose() -> None:
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]})
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame)
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame)
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)

msg = "The copy keyword is deprecated and will be removed in a future"
with pytest_warns_bounded(
DeprecationWarning,
msg,
lower="2.2.99",
):
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)


def test_combine() -> None:
Expand Down
27 changes: 19 additions & 8 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Union,
)

import matplotlib as mpl
from matplotlib.axes import Axes
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
Expand All @@ -13,6 +14,7 @@
import numpy.typing as npt
import pandas as pd
from pandas import Series
from pandas.util.version import Version
import pytest
from typing_extensions import assert_type

Expand Down Expand Up @@ -577,13 +579,22 @@ def test_plot_keywords(close_figures):
)

df = pd.DataFrame(np.random.rand(10, 5), columns=["A", "B", "C", "D", "E"])
check(
assert_type(
df.plot(kind="box", orientation="vertical", positions=[1, 4, 5, 6, 8]),
if Version(mpl.__version__) >= Version("3.10.1"):
check(
assert_type(
df.plot(kind="box", orientation="vertical", positions=[1, 4, 5, 6, 8]),
Axes,
),
Axes,
),
Axes,
)
)
else:
check(
assert_type(
df.plot(kind="box", vert=False, positions=[1, 4, 5, 6, 8]),
Axes,
),
Axes,
)


def test_plot_subplot_changes_150() -> None:
Expand All @@ -609,7 +620,7 @@ def test_grouped_dataframe_boxplot(close_figures):
check(assert_type(grouped.boxplot(subplots=True), Series), Series)

# a single plot
if not PD_LTE_22:
if not PD_LTE_22 and Version(mpl.__version__) >= Version("3.10.1"):
check(
assert_type(
grouped.boxplot(
Expand Down Expand Up @@ -654,7 +665,7 @@ def test_grouped_dataframe_boxplot_single(close_figures):
Axes,
)

if not PD_LTE_22:
if not PD_LTE_22 and Version(mpl.__version__) >= Version("3.10.1"):
check(
assert_type(
grouped.boxplot(
Expand Down
10 changes: 9 additions & 1 deletion tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3573,6 +3573,14 @@ def test_align() -> None:
aligned_s0, aligned_s1 = s0.align(s1)
check(assert_type(aligned_s0, pd.Series), pd.Series)
check(assert_type(aligned_s1, pd.Series), pd.Series)
aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False)

msg = "The copy keyword is deprecated and will be removed in a future version.*"
with pytest_warns_bounded(
DeprecationWarning,
msg,
lower="2.2.99",
):
aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False)

check(assert_type(aligned_s0, pd.Series), pd.Series)
check(assert_type(aligned_s1, pd.Series), pd.Series)