From e0b4e4cd0152a2fa90c90008c4dd9481359e4aa0 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Sun, 9 Mar 2025 10:35:28 -0400 Subject: [PATCH 1/5] GH1089 Fix pandas nightly with new warnings on copy --- tests/test_frame.py | 19 ++++++++++++++++--- tests/test_series.py | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/test_frame.py b/tests/test_frame.py index e82351552..165674443 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -3996,8 +3996,9 @@ def test_hashable_args() -> None: df.columns = ["test"] # type: ignore[assignment] testDict = {"test": 1} - df.to_string("test", col_space=testDict) - df.to_string("test", col_space={"test": 1}) + with ensure_clean() as path: + df.to_string(path, col_space=testDict) + df.to_string(path, col_space={"test": 1}) # GH 906 @@ -4009,7 +4010,19 @@ 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 = ( + r"The copy keyword is deprecated and will be removed in a future version\. Copy" + r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism" + r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if" + " necessary.*" + ) + 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: diff --git a/tests/test_series.py b/tests/test_series.py index 9bce2bd10..d5c481cd9 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -3714,6 +3714,19 @@ 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 = ( + r"The copy keyword is deprecated and will be removed in a future version\. Copy" + r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism" + r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if" + " necessary.*" + ) + 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) From 0bd57d0100484f590d9028ce8fe6ae848af73698 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 10 Mar 2025 18:23:13 -0400 Subject: [PATCH 2/5] GH1089 PR Feedback --- tests/test_frame.py | 7 +------ tests/test_series.py | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/test_frame.py b/tests/test_frame.py index 165674443..083854821 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -4011,12 +4011,7 @@ def test_transpose() -> None: check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame) check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame) - msg = ( - r"The copy keyword is deprecated and will be removed in a future version\. Copy" - r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism" - r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if" - " necessary.*" - ) + msg = "The copy keyword is deprecated and will be removed in a future" with pytest_warns_bounded( DeprecationWarning, msg, diff --git a/tests/test_series.py b/tests/test_series.py index d5c481cd9..7efab3b4a 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -3715,12 +3715,7 @@ def test_align() -> None: check(assert_type(aligned_s0, pd.Series), pd.Series) check(assert_type(aligned_s1, pd.Series), pd.Series) - msg = ( - r"The copy keyword is deprecated and will be removed in a future version\. Copy" - r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism" - r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if" - " necessary.*" - ) + msg = "The copy keyword is deprecated and will be removed in a future version.*" with pytest_warns_bounded( DeprecationWarning, msg, From e3d18b48e24b0c1e999cd41093af5926152007ae Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Tue, 11 Mar 2025 20:13:00 -0400 Subject: [PATCH 3/5] GH1089 PR Feedback --- tests/test_plotting.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index d89cab3c5..e8446865d 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -5,6 +5,7 @@ Union, ) +import matplotlib as mpl from matplotlib.axes import Axes from matplotlib.figure import Figure import matplotlib.pyplot as plt @@ -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 @@ -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: @@ -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( @@ -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( From 5050ffe2ff931f09b2c2688b15e792468fbc67ad Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Wed, 12 Mar 2025 22:00:36 -0400 Subject: [PATCH 4/5] GH1089 PR Feedback --- pyproject.toml | 2 +- tests/test_plotting.py | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2570e0898..ff1b75b53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ pyright = ">=1.1.396" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0" -matplotlib = ">=3.6.3" +matplotlib = ">=3.10.1" pre-commit = ">=2.19.0" black = ">=23.3.0" isort = ">=5.12.0" diff --git a/tests/test_plotting.py b/tests/test_plotting.py index e8446865d..d89cab3c5 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -5,7 +5,6 @@ Union, ) -import matplotlib as mpl from matplotlib.axes import Axes from matplotlib.figure import Figure import matplotlib.pyplot as plt @@ -14,7 +13,6 @@ 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 @@ -579,22 +577,13 @@ def test_plot_keywords(close_figures): ) df = pd.DataFrame(np.random.rand(10, 5), columns=["A", "B", "C", "D", "E"]) - 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, - ) - else: - check( - assert_type( - df.plot(kind="box", vert=False, positions=[1, 4, 5, 6, 8]), - Axes, - ), + check( + assert_type( + df.plot(kind="box", orientation="vertical", positions=[1, 4, 5, 6, 8]), Axes, - ) + ), + Axes, + ) def test_plot_subplot_changes_150() -> None: @@ -620,7 +609,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 and Version(mpl.__version__) >= Version("3.10.1"): + if not PD_LTE_22: check( assert_type( grouped.boxplot( @@ -665,7 +654,7 @@ def test_grouped_dataframe_boxplot_single(close_figures): Axes, ) - if not PD_LTE_22 and Version(mpl.__version__) >= Version("3.10.1"): + if not PD_LTE_22: check( assert_type( grouped.boxplot( From e37e56337ba7b8a87a7b901935d96a6c30682911 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Wed, 12 Mar 2025 22:32:42 -0400 Subject: [PATCH 5/5] GH1089 Block update of sqlalchemy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ff1b75b53..1a71a9bb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ xarray = ">=22.6.0" tabulate = ">=0.8.10" jinja2 = ">=3.1" scipy = { version = ">=1.9.1", python = "<3.14" } -SQLAlchemy = ">=2.0.12" +SQLAlchemy = ">=2.0.12,<2.0.39" types-python-dateutil = ">=2.8.19" beautifulsoup4 = ">=4.12.2" html5lib = ">=1.1"