Skip to content

for issue 429 #433

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ def test_groupby_series_methods() -> None:
gb.min().loc[2]
gb.nlargest().loc[2]
gb.nsmallest().loc[2]
gb.nth(0).loc[2]
gb.nth(0).loc[1]


def test_indexslice_setitem():
Expand Down
8 changes: 5 additions & 3 deletions tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from numpy import typing as npt
import pandas as pd
from pandas.core.indexes.numeric import NumericIndex
import pytest
from typing_extensions import assert_type

from tests import check
from tests import (
check,
pytest_warns_bounded,
)


def test_index_unique() -> None:
Expand Down Expand Up @@ -166,7 +168,7 @@ def test_index_relops() -> None:


def test_range_index_union():
with pytest.warns(FutureWarning, match="pandas.Int64Index"):
with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index", upper="1.5.99"):
check(
assert_type(
pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)),
Expand Down
13 changes: 10 additions & 3 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
pytest_warns_bounded,
)


Expand Down Expand Up @@ -752,14 +753,20 @@ def test_factorize() -> None:
def test_index_unqiue() -> None:
ci = pd.CategoricalIndex(["a", "b", "a", "c"])
dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)])
with pytest.warns(FutureWarning, match="pandas.Float64Index is deprecated"):
with pytest_warns_bounded(
FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99"
):
fi = pd.Float64Index([1.0, 2.0])
i = pd.Index(["a", "b", "c", "a"])
with pytest.warns(FutureWarning, match="pandas.Int64Index is deprecated"):
with pytest_warns_bounded(
FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99"
):
i64i = pd.Int64Index([1, 2, 3, 4])
pi = pd.period_range("2000Q1", periods=2, freq="Q")
ri = pd.RangeIndex(0, 10)
with pytest.warns(FutureWarning, match="pandas.UInt64Index is deprecated"):
with pytest_warns_bounded(
FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99"
):
ui = pd.UInt64Index([0, 1, 2, 3, 5])
tdi = pd.timedelta_range("1 day", "10 days", periods=10)
mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import numpy as np
from numpy import typing as npt
import pandas as pd
import pytest
import pytz
from typing_extensions import (
TypeAlias,
Expand All @@ -29,6 +28,7 @@
from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
pytest_warns_bounded,
)

from pandas.tseries.offsets import Day
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None:
def test_timedelta_mul_div() -> None:
td = pd.Timedelta("1 day")

with pytest.warns(FutureWarning):
with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""):
i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int))
f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float))

Expand Down Expand Up @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None:
def test_timedelta_mod_abs_unary() -> None:
td = pd.Timedelta("1 day")

with pytest.warns(FutureWarning):
with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""):
i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int))
f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float))

Expand Down
37 changes: 28 additions & 9 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
PD_LTE_15,
TYPE_CHECKING_INVALID_USAGE,
check,
pytest_warns_bounded,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -260,15 +261,25 @@ def test_types_shift() -> None:

def test_types_rank() -> None:
s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"])
with pytest.warns(FutureWarning, match="Dropping of nuisance columns"):
with pytest_warns_bounded(
FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"
):
s.rank()
with pytest.warns(FutureWarning, match="Dropping of nuisance columns"):
with pytest_warns_bounded(
FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"
):
s.rank(axis=0, na_option="bottom")
with pytest.warns(FutureWarning, match="Dropping of nuisance columns"):
with pytest_warns_bounded(
FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"
):
s.rank(method="min", pct=True)
with pytest.warns(FutureWarning, match="Dropping of nuisance columns"):
with pytest_warns_bounded(
FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"
):
s.rank(method="dense", ascending=True)
with pytest.warns(FutureWarning, match="Calling Series.rank with numeric_only"):
with pytest_warns_bounded(
FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99"
):
s.rank(method="first", numeric_only=True)
s2 = pd.Series([1, 1, 2, 5, 6, np.nan])
s2.rank(method="first", numeric_only=True)
Expand Down Expand Up @@ -643,17 +654,25 @@ def test_types_transform() -> None:

def test_types_describe() -> None:
s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")])
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
with pytest_warns_bounded(
DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"
):
s.describe()
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
with pytest_warns_bounded(
DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"
):
s.describe(percentiles=[0.5], include="all")
with pytest.warns(DeprecationWarning, match="elementwise comparison failed"):
with pytest_warns_bounded(
DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"
):
s.describe(exclude=np.number)
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"):
with pytest_warns_bounded(
DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"
):
s.describe(datetime_is_numeric=True)


Expand Down