@@ -543,14 +543,15 @@ def test_tda_add_sub_index(self):
543543
544544 def test_tda_add_dt64_object_array (self , box_df_fail , tz_naive_fixture ):
545545 # Result should be cast back to DatetimeArray
546+ box = box_df_fail
546547 dti = pd .date_range ("2016-01-01" , periods = 3 , tz = tz_naive_fixture )
547548 dti = dti ._with_freq (None )
548549 tdi = dti - dti
549550
550- obj = tm .box_expected (tdi , box_df_fail )
551- other = tm .box_expected (dti , box_df_fail )
551+ obj = tm .box_expected (tdi , box )
552+ other = tm .box_expected (dti , box )
552553
553- warn = PerformanceWarning if box_df_fail is not pd .DataFrame else None
554+ warn = PerformanceWarning if box is not pd .DataFrame else None
554555 with tm .assert_produces_warning (warn ):
555556 result = obj + other .astype (object )
556557 tm .assert_equal (result , other )
@@ -1195,16 +1196,19 @@ def test_td64arr_sub_td64_array(self, box_with_array):
11951196 result = tdarr - tdi
11961197 tm .assert_equal (result , expected )
11971198
1198- def test_td64arr_add_sub_tdi (self , box , names ):
1199+ def test_td64arr_add_sub_tdi (self , box_with_array , names ):
11991200 # GH#17250 make sure result dtype is correct
12001201 # GH#19043 make sure names are propagated correctly
1202+ box = box_with_array
1203+
12011204 if box is pd .DataFrame and names [1 ] != names [0 ]:
12021205 pytest .skip (
12031206 "Name propagation for DataFrame does not behave like "
12041207 "it does for Index/Series"
12051208 )
12061209
12071210 tdi = TimedeltaIndex (["0 days" , "1 day" ], name = names [0 ])
1211+ tdi = np .array (tdi ) if box is tm .to_array else tdi
12081212 ser = Series ([Timedelta (hours = 3 ), Timedelta (hours = 4 )], name = names [1 ])
12091213 expected = Series (
12101214 [Timedelta (hours = 3 ), Timedelta (days = 1 , hours = 4 )], name = names [2 ]
@@ -1299,8 +1303,10 @@ def test_td64arr_sub_timedeltalike(self, two_hours, box_with_array):
12991303 # ------------------------------------------------------------------
13001304 # __add__/__sub__ with DateOffsets and arrays of DateOffsets
13011305
1302- def test_td64arr_add_offset_index (self , names , box ):
1306+ def test_td64arr_add_offset_index (self , names , box_with_array ):
13031307 # GH#18849, GH#19744
1308+ box = box_with_array
1309+
13041310 if box is pd .DataFrame and names [1 ] != names [0 ]:
13051311 pytest .skip (
13061312 "Name propagation for DataFrame does not behave like "
@@ -1309,6 +1315,7 @@ def test_td64arr_add_offset_index(self, names, box):
13091315
13101316 tdi = TimedeltaIndex (["1 days 00:00:00" , "3 days 04:00:00" ], name = names [0 ])
13111317 other = pd .Index ([pd .offsets .Hour (n = 1 ), pd .offsets .Minute (n = - 2 )], name = names [1 ])
1318+ other = np .array (other ) if box is tm .to_array else other
13121319
13131320 expected = TimedeltaIndex (
13141321 [tdi [n ] + other [n ] for n in range (len (tdi ))], freq = "infer" , name = names [2 ]
@@ -1347,16 +1354,13 @@ def test_td64arr_add_offset_array(self, box_with_array):
13471354 res2 = other + tdi
13481355 tm .assert_equal (res2 , expected )
13491356
1350- @pytest .mark .parametrize (
1351- "names" , [(None , None , None ), ("foo" , "bar" , None ), ("foo" , "foo" , "foo" )]
1352- )
13531357 def test_td64arr_sub_offset_index (self , names , box_with_array ):
13541358 # GH#18824, GH#19744
13551359 box = box_with_array
13561360 xbox = box if box is not tm .to_array else pd .Index
13571361 exname = names [2 ] if box is not tm .to_array else names [1 ]
13581362
1359- if box is pd .DataFrame and names [1 ] == "bar" :
1363+ if box is pd .DataFrame and names [1 ] != names [ 0 ] :
13601364 pytest .skip (
13611365 "Name propagation for DataFrame does not behave like "
13621366 "it does for Index/Series"
@@ -1392,9 +1396,6 @@ def test_td64arr_sub_offset_array(self, box_with_array):
13921396 res = tdi - other
13931397 tm .assert_equal (res , expected )
13941398
1395- @pytest .mark .parametrize (
1396- "names" , [(None , None , None ), ("foo" , "bar" , None ), ("foo" , "foo" , "foo" )]
1397- )
13981399 def test_td64arr_with_offset_series (self , names , box_df_fail ):
13991400 # GH#18849
14001401 box = box_df_fail
@@ -2030,9 +2031,13 @@ def test_td64arr_div_numeric_array(self, box_with_array, vector, any_real_dtype)
20302031 with pytest .raises (TypeError , match = pattern ):
20312032 vector .astype (object ) / tdser
20322033
2033- def test_td64arr_mul_int_series (self , box_df_fail , names ):
2034+ def test_td64arr_mul_int_series (self , box_with_array , names , request ):
20342035 # GH#19042 test for correct name attachment
2035- box = box_df_fail # broadcasts along wrong axis, but doesn't raise
2036+ box = box_with_array
2037+ if box_with_array is pd .DataFrame and names [2 ] is None :
2038+ reason = "broadcasts along wrong axis, but doesn't raise"
2039+ request .node .add_marker (pytest .mark .xfail (reason = reason ))
2040+
20362041 exname = names [2 ] if box is not tm .to_array else names [1 ]
20372042
20382043 tdi = TimedeltaIndex (
@@ -2056,7 +2061,10 @@ def test_td64arr_mul_int_series(self, box_df_fail, names):
20562061
20572062 # The direct operation tdi * ser still needs to be fixed.
20582063 result = ser .__rmul__ (tdi )
2059- tm .assert_equal (result , expected )
2064+ if box is pd .DataFrame :
2065+ assert result is NotImplemented
2066+ else :
2067+ tm .assert_equal (result , expected )
20602068
20612069 # TODO: Should we be parametrizing over types for `ser` too?
20622070 def test_float_series_rdiv_td64arr (self , box_with_array , names ):
0 commit comments