From e4204ca4b2649897f9e0f84c4c58684c9a27806a Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Fri, 6 Jan 2023 20:47:16 -0500 Subject: [PATCH 1/2] fix nightly build with Series.to_numpy() on a Timedelta series --- tests/test_timefuncs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index dc74a37d4..348d75d55 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -28,6 +28,7 @@ else: FulldatetimeDict = Any from tests import ( + PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -652,7 +653,12 @@ def test_types_to_numpy() -> None: td_s = pd.to_timedelta(pd.Series([10, 20]), "minutes") check(assert_type(td_s.to_numpy(), np.ndarray), np.ndarray) check(assert_type(td_s.to_numpy(dtype="int", copy=True), np.ndarray), np.ndarray) - check(assert_type(td_s.to_numpy(na_value=0), np.ndarray), np.ndarray) + if PD_LTE_15: + check(assert_type(td_s.to_numpy(na_value=0), np.ndarray), np.ndarray) + else: + check( + assert_type(td_s.to_numpy(na_value=pd.Timedelta(0)), np.ndarray), np.ndarray + ) def test_to_timdelta_units() -> None: From c9ed1574d78ca4252b41c880a4f05dddc8f16d58 Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Fri, 6 Jan 2023 21:49:01 -0500 Subject: [PATCH 2/2] just use Timedelta(0) --- tests/test_timefuncs.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 348d75d55..23e3e2839 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -28,7 +28,6 @@ else: FulldatetimeDict = Any from tests import ( - PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -653,12 +652,7 @@ def test_types_to_numpy() -> None: td_s = pd.to_timedelta(pd.Series([10, 20]), "minutes") check(assert_type(td_s.to_numpy(), np.ndarray), np.ndarray) check(assert_type(td_s.to_numpy(dtype="int", copy=True), np.ndarray), np.ndarray) - if PD_LTE_15: - check(assert_type(td_s.to_numpy(na_value=0), np.ndarray), np.ndarray) - else: - check( - assert_type(td_s.to_numpy(na_value=pd.Timedelta(0)), np.ndarray), np.ndarray - ) + check(assert_type(td_s.to_numpy(na_value=pd.Timedelta(0)), np.ndarray), np.ndarray) def test_to_timdelta_units() -> None: