Skip to content

Commit b3967c9

Browse files
Restore nightly CI build due to new pandas version (3.0.0) (#974)
* GH 927 Allow 'integer' in select_dtypes include argument * TypeGuard clean up in dtypes/missing.pyi * PR Feedback * Restore pandas nightly CI build * Correct freq in test
1 parent 1896191 commit b3967c9

File tree

6 files changed

+127
-26
lines changed

6 files changed

+127
-26
lines changed

tests/test_frame.py

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,13 @@ def test_types_to_html() -> None:
14461446
def test_types_resample() -> None:
14471447
df = pd.DataFrame({"values": [2, 11, 3, 13, 14, 18, 17, 19]})
14481448
df["date"] = pd.date_range("01/01/2018", periods=8, freq="W")
1449-
with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"):
1449+
with pytest_warns_bounded(
1450+
FutureWarning,
1451+
"'M' is deprecated",
1452+
lower="2.1.99",
1453+
upper="2.2.99",
1454+
upper_exception=ValueError,
1455+
):
14501456
df.resample("M", on="date")
14511457
df.resample("20min", origin="epoch", offset=pd.Timedelta(2, "minutes"), on="date")
14521458
df.resample("20min", origin="epoch", offset=datetime.timedelta(2), on="date")
@@ -1583,8 +1589,14 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
15831589
assert isinstance(resampler, Resampler)
15841590
return pd.DataFrame(resampler)
15851591

1586-
with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"):
1587-
val = (
1592+
with pytest_warns_bounded(
1593+
FutureWarning,
1594+
"'M' is deprecated",
1595+
lower="2.1.99",
1596+
upper="2.2.99",
1597+
upper_exception=ValueError,
1598+
):
1599+
(
15881600
pd.DataFrame(
15891601
{
15901602
"price": [10, 11, 9, 13, 14, 18, 17, 19],
@@ -1596,6 +1608,18 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
15961608
.pipe(resampler_foo)
15971609
)
15981610

1611+
val = (
1612+
pd.DataFrame(
1613+
{
1614+
"price": [10, 11, 9, 13, 14, 18, 17, 19],
1615+
"volume": [50, 60, 40, 100, 50, 100, 40, 50],
1616+
}
1617+
)
1618+
.assign(week_starting=pd.date_range("01/01/2018", periods=8, freq="W"))
1619+
.resample("MS", on="week_starting")
1620+
.pipe(resampler_foo)
1621+
)
1622+
15991623
def foo(df: pd.DataFrame) -> pd.DataFrame:
16001624
return pd.DataFrame(df)
16011625

@@ -1854,11 +1878,22 @@ def test_types_regressions() -> None:
18541878
d: datetime.date = pd.Timestamp("2021-01-01")
18551879
tslist: list[pd.Timestamp] = list(pd.to_datetime(["2022-01-01", "2022-01-02"]))
18561880
sseries: pd.Series = pd.Series(tslist)
1857-
sseries_plus1: pd.Series = sseries + pd.Timedelta(1, "d")
1881+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
1882+
sseries + pd.Timedelta(1, "d")
1883+
1884+
sseries_plus1: pd.Series = sseries + pd.Timedelta(1, "D")
18581885

18591886
# https://github.com/microsoft/pylance-release/issues/2133
1860-
with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"):
1861-
dr = pd.date_range(start="2021-12-01", periods=24, freq="H")
1887+
with pytest_warns_bounded(
1888+
FutureWarning,
1889+
"'H' is deprecated",
1890+
lower="2.1.99",
1891+
upper="2.2.99",
1892+
upper_exception=ValueError,
1893+
):
1894+
pd.date_range(start="2021-12-01", periods=24, freq="H")
1895+
1896+
dr = pd.date_range(start="2021-12-01", periods=24, freq="h")
18621897
time = dr.strftime("%H:%M:%S")
18631898

18641899
# https://github.com/microsoft/python-type-stubs/issues/115
@@ -2885,8 +2920,16 @@ def test_quantile_150_changes() -> None:
28852920
def test_resample_150_changes() -> None:
28862921
idx = pd.date_range("2020-1-1", periods=700)
28872922
frame = pd.DataFrame(np.random.standard_normal((700, 1)), index=idx, columns=["a"])
2888-
with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"):
2889-
resampler = frame.resample("M", group_keys=True)
2923+
with pytest_warns_bounded(
2924+
FutureWarning,
2925+
"'M' is deprecated",
2926+
lower="2.1.99",
2927+
upper="2.2.99",
2928+
upper_exception=ValueError,
2929+
):
2930+
frame.resample("M", group_keys=True)
2931+
2932+
resampler = frame.resample("MS", group_keys=True)
28902933
check(
28912934
assert_type(resampler, "DatetimeIndexResampler[pd.DataFrame]"),
28922935
DatetimeIndexResampler,

tests/test_indexes.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,13 @@ def test_interval_range():
259259
pd.IntervalIndex,
260260
pd.Interval,
261261
)
262-
with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"):
262+
with pytest_warns_bounded(
263+
FutureWarning,
264+
"'M' is deprecated",
265+
lower="2.1.99",
266+
upper="2.2.99",
267+
upper_exception=ValueError,
268+
):
263269
check(
264270
assert_type(
265271
pd.interval_range(
@@ -577,9 +583,18 @@ def test_interval_index_arrays():
577583
pd.IntervalIndex,
578584
pd.Interval,
579585
)
580-
with pytest_warns_bounded(FutureWarning, "'Y' is deprecated", lower="2.1.99"):
581-
left_s_ts = pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="Y"))
582-
right_s_ts = pd.Series(pd.date_range("2001-01-01", "2004-01-01", freq="Y"))
586+
with pytest_warns_bounded(
587+
FutureWarning,
588+
"'Y' is deprecated",
589+
lower="2.1.99",
590+
upper="2.2.99",
591+
upper_exception=ValueError,
592+
):
593+
pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="Y"))
594+
pd.Series(pd.date_range("2001-01-01", "2004-01-01", freq="Y"))
595+
596+
left_s_ts = pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="YS"))
597+
right_s_ts = pd.Series(pd.date_range("2001-01-01", "2004-01-01", freq="YS"))
583598
check(
584599
assert_type(
585600
pd.IntervalIndex.from_arrays(left_s_ts, right_s_ts),
@@ -989,7 +1004,13 @@ def test_index_constructors():
9891004

9901005
def test_iter() -> None:
9911006
# GH 723
992-
with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"):
1007+
with pytest_warns_bounded(
1008+
FutureWarning,
1009+
"'H' is deprecated",
1010+
lower="2.1.99",
1011+
upper="2.2.99",
1012+
upper_exception=ValueError,
1013+
):
9931014
for ts in pd.date_range(start="1/1/2023", end="1/08/2023", freq="6H"):
9941015
check(assert_type(ts, pd.Timestamp), pd.Timestamp)
9951016

tests/test_pandas.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,13 @@ def g(x: pd.Series) -> int:
19801980
},
19811981
index=idx,
19821982
)
1983-
with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"):
1983+
with pytest_warns_bounded(
1984+
FutureWarning,
1985+
"'M' is deprecated",
1986+
lower="2.1.99",
1987+
upper="2.2.99",
1988+
upper_exception=ValueError,
1989+
):
19841990
check(
19851991
assert_type(
19861992
pd.pivot_table(
@@ -1990,7 +1996,13 @@ def g(x: pd.Series) -> int:
19901996
),
19911997
pd.DataFrame,
19921998
)
1993-
with pytest_warns_bounded(FutureWarning, "'(M|A)' is deprecated", lower="2.1.99"):
1999+
with pytest_warns_bounded(
2000+
FutureWarning,
2001+
"'(M|A)' is deprecated",
2002+
lower="2.1.99",
2003+
upper="2.2.99",
2004+
upper_exception=ValueError,
2005+
):
19942006
check(
19952007
assert_type(
19962008
pd.pivot_table(

tests/test_scalars.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,11 @@ def test_interval_cmp():
386386

387387
def test_timedelta_construction() -> None:
388388
check(assert_type(pd.Timedelta(1, "W"), pd.Timedelta), pd.Timedelta)
389-
check(assert_type(pd.Timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
389+
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"):
390+
check(assert_type(pd.Timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
390391
check(assert_type(pd.Timedelta(1, "D"), pd.Timedelta), pd.Timedelta)
391-
check(assert_type(pd.Timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
392+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
393+
check(assert_type(pd.Timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
392394
check(assert_type(pd.Timedelta(1, "days"), pd.Timedelta), pd.Timedelta)
393395
check(assert_type(pd.Timedelta(1, "day"), pd.Timedelta), pd.Timedelta)
394396
check(assert_type(pd.Timedelta(1, "hours"), pd.Timedelta), pd.Timedelta)
@@ -421,9 +423,11 @@ def test_timedelta_construction() -> None:
421423
check(assert_type(pd.Timedelta(1, "nanosecond"), pd.Timedelta), pd.Timedelta)
422424

423425
check(assert_type(pd.Timedelta("1 W"), pd.Timedelta), pd.Timedelta)
424-
check(assert_type(pd.Timedelta("1 w"), pd.Timedelta), pd.Timedelta)
426+
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"):
427+
check(assert_type(pd.Timedelta("1 w"), pd.Timedelta), pd.Timedelta)
425428
check(assert_type(pd.Timedelta("1 D"), pd.Timedelta), pd.Timedelta)
426-
check(assert_type(pd.Timedelta("1 d"), pd.Timedelta), pd.Timedelta)
429+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
430+
check(assert_type(pd.Timedelta("1 d"), pd.Timedelta), pd.Timedelta)
427431
check(assert_type(pd.Timedelta("1 days"), pd.Timedelta), pd.Timedelta)
428432
check(assert_type(pd.Timedelta("1 day"), pd.Timedelta), pd.Timedelta)
429433
check(assert_type(pd.Timedelta("1 hours"), pd.Timedelta), pd.Timedelta)
@@ -1518,7 +1522,13 @@ def test_timestamp_misc_methods() -> None:
15181522
check(assert_type(ts2.round("1s", ambiguous=False), pd.Timestamp), pd.Timestamp)
15191523
check(assert_type(ts2.round("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp)
15201524

1521-
with pytest_warns_bounded(FutureWarning, "'H' is deprecated ", lower="2.1.99"):
1525+
with pytest_warns_bounded(
1526+
FutureWarning,
1527+
"'H' is deprecated ",
1528+
lower="2.1.99",
1529+
upper="2.2.99",
1530+
upper_exception=ValueError,
1531+
):
15221532
check(
15231533
assert_type(ts2.round("2H", nonexistent="shift_forward"), pd.Timestamp),
15241534
pd.Timestamp,
@@ -1553,7 +1563,13 @@ def test_timestamp_misc_methods() -> None:
15531563
check(assert_type(ts2.ceil("1s", ambiguous=False), pd.Timestamp), pd.Timestamp)
15541564
check(assert_type(ts2.ceil("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp)
15551565

1556-
with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"):
1566+
with pytest_warns_bounded(
1567+
FutureWarning,
1568+
"'H' is deprecated",
1569+
lower="2.1.99",
1570+
upper="2.2.99",
1571+
upper_exception=ValueError,
1572+
):
15571573
check(
15581574
assert_type(ts2.ceil("2H", nonexistent="shift_forward"), pd.Timestamp),
15591575
pd.Timestamp,
@@ -1587,7 +1603,13 @@ def test_timestamp_misc_methods() -> None:
15871603
check(assert_type(ts2.floor("1s", ambiguous=False), pd.Timestamp), pd.Timestamp)
15881604
check(assert_type(ts2.floor("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp)
15891605

1590-
with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"):
1606+
with pytest_warns_bounded(
1607+
FutureWarning,
1608+
"'H' is deprecated",
1609+
lower="2.1.99",
1610+
upper="2.2.99",
1611+
upper_exception=ValueError,
1612+
):
15911613
check(
15921614
assert_type(ts2.floor("2H", nonexistent="shift_forward"), pd.Timestamp),
15931615
pd.Timestamp,

tests/test_timefuncs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,13 @@ def test_types_to_numpy() -> None:
757757
check(assert_type(td_s.to_numpy(na_value=pd.Timedelta(0)), np.ndarray), np.ndarray)
758758

759759

760-
def test_to_timdelta_units() -> None:
760+
def test_to_timedelta_units() -> None:
761761
check(assert_type(pd.to_timedelta(1, "W"), pd.Timedelta), pd.Timedelta)
762-
check(assert_type(pd.to_timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
762+
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"):
763+
check(assert_type(pd.to_timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
763764
check(assert_type(pd.to_timedelta(1, "D"), pd.Timedelta), pd.Timedelta)
764-
check(assert_type(pd.to_timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
765+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
766+
check(assert_type(pd.to_timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
765767
check(assert_type(pd.to_timedelta(1, "days"), pd.Timedelta), pd.Timedelta)
766768
check(assert_type(pd.to_timedelta(1, "day"), pd.Timedelta), pd.Timedelta)
767769
check(assert_type(pd.to_timedelta(1, "hours"), pd.Timedelta), pd.Timedelta)

tests/test_utility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from tests import (
1212
NUMPY20,
13+
PD_LTE_22,
1314
check,
1415
pytest_warns_bounded,
1516
)
@@ -23,7 +24,7 @@ def test_show_version():
2324
version_str=platform.python_version(),
2425
):
2526
context: AbstractContextManager
26-
if NUMPY20: # https://github.com/PyTables/PyTables/issues/1172
27+
if PD_LTE_22 and NUMPY20: # https://github.com/PyTables/PyTables/issues/1172
2728
context = pytest.raises(ValueError)
2829
else:
2930
context = nullcontext()

0 commit comments

Comments
 (0)