Skip to content

Commit 5d4a616

Browse files
committed
MAINT: Fix for future change
1 parent 001c0af commit 5d4a616

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

tests/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
Final,
88
)
99

10+
from packaging.version import parse
11+
import pandas as pd
12+
1013
from pandas._typing import T
1114

1215
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
1316
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
17+
PD_LTE_15 = parse(pd.__version__) < parse("1.5.999")
1418

1519

1620
def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:

tests/test_frame.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from pandas._typing import Scalar
3737

3838
from tests import (
39+
PD_LTE_15,
3940
TYPE_CHECKING_INVALID_USAGE,
4041
check,
4142
)
@@ -933,12 +934,21 @@ def test_types_describe() -> None:
933934
}
934935
)
935936
df.describe()
936-
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
937+
if PD_LTE_15:
938+
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
939+
df.describe(percentiles=[0.5], include="all")
940+
else:
937941
df.describe(percentiles=[0.5], include="all")
938-
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
939-
df.describe(exclude=[np.number])
940-
# datetime_is_numeric param added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
941-
df.describe(datetime_is_numeric=True)
942+
if PD_LTE_15:
943+
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
944+
df.describe(exclude=[np.number])
945+
else:
946+
df.describe(percentiles=[0.5], include="all")
947+
if PD_LTE_15:
948+
# datetime_is_numeric param added in 1.1.0
949+
# https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
950+
# Remove in 2.0.0
951+
df.describe(datetime_is_numeric=True)
942952

943953

944954
def test_types_to_string() -> None:

tests/test_series.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
)
3434

3535
from tests import (
36+
PD_LTE_15,
3637
TYPE_CHECKING_INVALID_USAGE,
3738
check,
3839
)
@@ -649,8 +650,12 @@ def test_types_describe() -> None:
649650
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
650651
s.describe(exclude=np.number)
651652
# datetime_is_numeric param added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
652-
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
653-
s.describe(datetime_is_numeric=True)
653+
if PD_LTE_15:
654+
# datetime_is_numeric param added in 1.1.0
655+
# https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
656+
# Remove in 2.0.0
657+
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
658+
s.describe(datetime_is_numeric=True)
654659

655660

656661
def test_types_resample() -> None:

0 commit comments

Comments
 (0)