Skip to content
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
18 changes: 13 additions & 5 deletions tests/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3855,11 +3855,19 @@ def test_series_reindex() -> None:
def test_series_reindex_like() -> None:
s = pd.Series([1, 2, 3], index=[0, 1, 2])
other = pd.Series([1, 2], index=[1, 0])
with pytest_warns_bounded(
FutureWarning,
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.3.99",
upper="3.0.99",
with (
pytest_warns_bounded(
FutureWarning,
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.3.99",
upper="2.99",
),
pytest_warns_bounded(
Warning, # should be Pandas4Warning but only exposed starting pandas 3.0.0
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.99",
upper="3.0.99",
),
):
check(
assert_type(
Expand Down
17 changes: 13 additions & 4 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3254,10 +3254,19 @@ def test_frame_reindex_like() -> None:
# GH 84
df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2])
other = pd.DataFrame({"a": [1, 2]}, index=[1, 0])
with pytest_warns_bounded(
FutureWarning,
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.3.99",
with (
pytest_warns_bounded(
FutureWarning,
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.3.99",
upper="2.99",
),
pytest_warns_bounded(
Warning, # should be Pandas4Warning but only exposed starting pandas 3.0.0
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
lower="2.99",
upper="3.0.99",
),
):
check(
assert_type(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,9 @@ def test_datetimeindex_shift() -> None:

def test_timedeltaindex_shift() -> None:
ind = pd.date_range("1/1/2021", "1/5/2021") - pd.Timestamp("1/3/2019")
check(assert_type(ind.shift(1), pd.TimedeltaIndex), pd.TimedeltaIndex)
if PD_LTE_23:
# cannot shift with no freq starting in pandas 3.0.0
check(assert_type(ind.shift(1), pd.TimedeltaIndex), pd.TimedeltaIndex)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug in main right now, and there is a PR to fix it, so let's not make this change. See pandas-dev/pandas#62094 and the associated PR. I'm fine to live with nightly broke on this for now given it will get fixed within a few days.



def test_index_insert() -> None:
Expand Down
35 changes: 22 additions & 13 deletions tests/test_timefuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def test_types_init() -> None:


def test_types_arithmetic() -> None:
ts: pd.Timestamp = pd.to_datetime("2021-03-01")
ts2: pd.Timestamp = pd.to_datetime("2021-01-01")
delta: pd.Timedelta = pd.to_timedelta("1 day")
ts = pd.to_datetime("2021-03-01")
ts2 = pd.to_datetime("2021-01-01")
delta = pd.to_timedelta("1 day")

check(assert_type(ts - ts2, pd.Timedelta), pd.Timedelta)
check(assert_type(ts + delta, pd.Timestamp), pd.Timestamp)
Expand All @@ -106,8 +106,8 @@ def test_types_arithmetic() -> None:


def test_types_comparison() -> None:
ts: pd.Timestamp = pd.to_datetime("2021-03-01")
ts2: pd.Timestamp = pd.to_datetime("2021-01-01")
ts = pd.to_datetime("2021-03-01")
ts2 = pd.to_datetime("2021-01-01")

check(assert_type(ts < ts2, bool), bool)
check(assert_type(ts > ts2, bool), bool)
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_types_timestamp_series_comparisons() -> None:


def test_types_pydatetime() -> None:
ts: pd.Timestamp = pd.Timestamp("2021-03-01T12")
ts = pd.Timestamp("2021-03-01T12")

check(assert_type(ts.to_pydatetime(), dt.datetime), dt.datetime)
check(assert_type(ts.to_pydatetime(False), dt.datetime), dt.datetime)
Expand All @@ -152,9 +152,9 @@ def test_to_timedelta() -> None:


def test_timedelta_arithmetic() -> None:
td1: pd.Timedelta = pd.to_timedelta(3, "days")
td2: pd.Timedelta = pd.to_timedelta(4, "hours")
td3: pd.Timedelta = td1 + td2
td1 = pd.to_timedelta(3, "days")
td2 = pd.to_timedelta(4, "hours")
td3 = td1 + td2
check(assert_type(td1 - td2, pd.Timedelta), pd.Timedelta)
check(assert_type(td1 * 4.3, pd.Timedelta), pd.Timedelta)
check(assert_type(td3 / 10.2, pd.Timedelta), pd.Timedelta)
Expand Down Expand Up @@ -541,10 +541,19 @@ def test_series_dt_accessors() -> None:
check(assert_type(s2.dt.microseconds, "pd.Series[int]"), pd.Series, np.integer)
check(assert_type(s2.dt.nanoseconds, "pd.Series[int]"), pd.Series, np.integer)
check(assert_type(s2.dt.components, pd.DataFrame), pd.DataFrame)
with pytest_warns_bounded(
FutureWarning,
"The behavior of TimedeltaProperties.to_pytimedelta is deprecated",
lower="2.3.99",
with (
pytest_warns_bounded(
FutureWarning,
"The behavior of TimedeltaProperties.to_pytimedelta is deprecated",
lower="2.3.99",
upper="2.99",
),
pytest_warns_bounded(
Warning, # should be Pandas4Warning but only exposed starting pandas 3.0.0
"The behavior of TimedeltaProperties.to_pytimedelta is deprecated",
lower="2.99",
upper="3.0.99",
),
):
check(assert_type(s2.dt.to_pytimedelta(), np.ndarray), np.ndarray)
check(assert_type(s2.dt.total_seconds(), "pd.Series[float]"), pd.Series, float)
Expand Down
Loading