Skip to content

MAINT: Fix for future change #409

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 7 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
Final,
)

from packaging.version import parse
import pandas as pd

from pandas._typing import T

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


def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:
Expand Down
20 changes: 15 additions & 5 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from pandas._typing import Scalar

from tests import (
PD_LTE_15,
TYPE_CHECKING_INVALID_USAGE,
check,
)
Expand Down Expand Up @@ -933,12 +934,21 @@ def test_types_describe() -> None:
}
)
df.describe()
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
if PD_LTE_15:
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
df.describe(percentiles=[0.5], include="all")
else:
df.describe(percentiles=[0.5], include="all")
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
df.describe(exclude=[np.number])
# datetime_is_numeric param added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
df.describe(datetime_is_numeric=True)
if PD_LTE_15:
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
df.describe(exclude=[np.number])
else:
df.describe(percentiles=[0.5], include="all")
if PD_LTE_15:
# datetime_is_numeric param added in 1.1.0
# https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
# Remove in 2.0.0
df.describe(datetime_is_numeric=True)


def test_types_to_string() -> None:
Expand Down
9 changes: 7 additions & 2 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)

from tests import (
PD_LTE_15,
TYPE_CHECKING_INVALID_USAGE,
check,
)
Expand Down Expand Up @@ -649,8 +650,12 @@ def test_types_describe() -> None:
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
s.describe(exclude=np.number)
# datetime_is_numeric param added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
s.describe(datetime_is_numeric=True)
if PD_LTE_15:
# datetime_is_numeric param added in 1.1.0
# https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
# Remove in 2.0.0
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
s.describe(datetime_is_numeric=True)


def test_types_resample() -> None:
Expand Down