@@ -83,11 +83,13 @@ def temporal_dfs(session):
8383
8484
8585def _assert_series_equal (actual : pd .Series , expected : pd .Series ):
86- """Helper function specifically for timedelta testsing. Don't use it outside of this module."""
86+ """Helper function specifically for timedelta testing. Don't use it outside of this module."""
87+ # expected[expected.select_dtypes('timedelta64').columns] = expected.select_dtypes('timedelta64').astype(dtypes.TIMEDELTA_DTYPE)
8788 bigframes .testing .assert_series_equal (
8889 actual ,
89- expected ,
90+ expected , # .convert_dtypes(dtype_backend="pyarrow"),
9091 check_index_type = False ,
92+ check_dtype = False ,
9193 )
9294
9395
@@ -117,15 +119,15 @@ def test_timedelta_binary_ops_between_series(temporal_dfs, op, col_1, col_2):
117119@pytest .mark .parametrize (
118120 ("op" , "col" , "literal" ),
119121 [
120- (operator .add , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
121- (operator .sub , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
122- (operator .truediv , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
123- (operator .floordiv , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
122+ (operator .add , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
123+ (operator .sub , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
124+ (operator .truediv , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
125+ (operator .floordiv , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
124126 (operator .truediv , "timedelta_col_1" , 3 ),
125127 (operator .floordiv , "timedelta_col_1" , 3 ),
126128 (operator .mul , "timedelta_col_1" , 3 ),
127- (operator .mul , "float_col" , pd .Timedelta (1 , "s" )),
128- (operator .mod , "timedelta_col_1" , pd .Timedelta (7 , "s" )),
129+ (operator .mul , "float_col" , pd .Timedelta (1 , "s" ). as_unit ( "us" ) ),
130+ (operator .mod , "timedelta_col_1" , pd .Timedelta (7 , "s" ). as_unit ( "us" ) ),
129131 ],
130132)
131133def test_timedelta_binary_ops_series_and_literal (temporal_dfs , op , col , literal ):
@@ -140,15 +142,15 @@ def test_timedelta_binary_ops_series_and_literal(temporal_dfs, op, col, literal)
140142@pytest .mark .parametrize (
141143 ("op" , "col" , "literal" ),
142144 [
143- (operator .add , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
144- (operator .sub , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
145- (operator .truediv , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
146- (operator .floordiv , "timedelta_col_1" , pd .Timedelta (2 , "s" )),
147- (operator .truediv , "float_col" , pd .Timedelta (2 , "s" )),
148- (operator .floordiv , "float_col" , pd .Timedelta (2 , "s" )),
145+ (operator .add , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
146+ (operator .sub , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
147+ (operator .truediv , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
148+ (operator .floordiv , "timedelta_col_1" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
149+ (operator .truediv , "float_col" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
150+ (operator .floordiv , "float_col" , pd .Timedelta (2 , "s" ). as_unit ( "us" ) ),
149151 (operator .mul , "timedelta_col_1" , 3 ),
150- (operator .mul , "float_col" , pd .Timedelta (1 , "s" )),
151- (operator .mod , "timedelta_col_1" , pd .Timedelta (7 , "s" )),
152+ (operator .mul , "float_col" , pd .Timedelta (1 , "s" ). as_unit ( "us" ) ),
153+ (operator .mod , "timedelta_col_1" , pd .Timedelta (7 , "s" ). as_unit ( "us" ) ),
152154 ],
153155)
154156def test_timedelta_binary_ops_literal_and_series (temporal_dfs , op , col , literal ):
@@ -201,7 +203,7 @@ def test_timestamp_add__ts_series_plus_td_series__explicit_cast(temporal_dfs, co
201203@pytest .mark .parametrize (
202204 "literal" ,
203205 [
204- pytest .param (pd .Timedelta (1 , unit = "s" ), id = "pandas" ),
206+ pytest .param (pd .Timedelta (1 , unit = "s" ). as_unit ( "us" ) , id = "pandas" ),
205207 pytest .param (datetime .timedelta (seconds = 1 ), id = "python-datetime" ),
206208 pytest .param (np .timedelta64 (1 , "s" ), id = "numpy" ),
207209 ],
@@ -237,7 +239,7 @@ def test_timestamp_add__td_series_plus_ts_series(temporal_dfs, column, pd_dtype)
237239
238240def test_timestamp_add__td_literal_plus_ts_series (temporal_dfs ):
239241 bf_df , pd_df = temporal_dfs
240- timedelta = pd .Timedelta (1 , unit = "s" )
242+ timedelta = pd .Timedelta (1 , unit = "s" ). as_unit ( "us" )
241243
242244 actual_result = (timedelta + bf_df ["datetime_col" ]).to_pandas ()
243245
@@ -279,7 +281,7 @@ def test_timestamp_add_with_numpy_op(temporal_dfs, column, pd_dtype):
279281
280282def test_timestamp_add_dataframes (temporal_dfs ):
281283 columns = ["datetime_col" , "timestamp_col" ]
282- timedelta = pd .Timedelta (1 , unit = "s" )
284+ timedelta = pd .Timedelta (1 , unit = "s" ). as_unit ( "us" )
283285 bf_df , pd_df = temporal_dfs
284286
285287 actual_result = (bf_df [columns ] + timedelta ).to_pandas ()
@@ -363,7 +365,7 @@ def test_timestamp_sub_with_numpy_op(temporal_dfs, column, pd_dtype):
363365
364366def test_timestamp_sub_dataframes (temporal_dfs ):
365367 columns = ["datetime_col" , "timestamp_col" ]
366- timedelta = pd .Timedelta (1 , unit = "s" )
368+ timedelta = pd .Timedelta (1 , unit = "s" ). as_unit ( "us" )
367369 bf_df , pd_df = temporal_dfs
368370
369371 actual_result = (bf_df [columns ] - timedelta ).to_pandas ()
@@ -490,7 +492,7 @@ def test_timedelta_series_comparison(temporal_dfs, compare_func):
490492)
491493def test_timedelta_series_and_literal_comparison (temporal_dfs , compare_func ):
492494 bf_df , pd_df = temporal_dfs
493- literal = pd .Timedelta (3 , "s" )
495+ literal = pd .Timedelta (3 , "s" ). as_unit ( "us" )
494496
495497 actual_result = compare_func (literal , bf_df ["timedelta_col_2" ]).to_pandas ()
496498
0 commit comments