@@ -148,15 +148,11 @@ def test_numeric_arr_mul_tdscalar(self, scalar_td, numeric_idx, box):
148
148
tm .assert_equal (commute , expected )
149
149
150
150
def test_numeric_arr_rdiv_tdscalar (self , three_days , numeric_idx , box ):
151
- index = numeric_idx [1 :3 ]
152
151
153
- broken = (isinstance (three_days , np .timedelta64 ) and
154
- three_days .dtype != 'm8[ns]' )
155
- broken = broken or isinstance (three_days , pd .offsets .Tick )
156
- if box is not pd .Index and broken :
157
- # np.timedelta64(3, 'D') / 2 == np.timedelta64(1, 'D')
158
- raise pytest .xfail ("timedelta64 not converted to nanos; "
159
- "Tick division not implemented" )
152
+ if box is not pd .Index and isinstance (three_days , pd .offsets .Tick ):
153
+ raise pytest .xfail ("Tick division not implemented" )
154
+
155
+ index = numeric_idx [1 :3 ]
160
156
161
157
expected = TimedeltaIndex (['3 Days' , '36 Hours' ])
162
158
@@ -169,6 +165,26 @@ def test_numeric_arr_rdiv_tdscalar(self, three_days, numeric_idx, box):
169
165
with pytest .raises (TypeError ):
170
166
index / three_days
171
167
168
+ @pytest .mark .parametrize ('other' , [
169
+ pd .Timedelta (hours = 31 ),
170
+ pd .Timedelta (hours = 31 ).to_pytimedelta (),
171
+ pd .Timedelta (hours = 31 ).to_timedelta64 (),
172
+ pd .Timedelta (hours = 31 ).to_timedelta64 ().astype ('m8[h]' ),
173
+ np .timedelta64 ('NaT' ),
174
+ np .timedelta64 ('NaT' , 'D' ),
175
+ pd .offsets .Minute (3 ),
176
+ pd .offsets .Second (0 )])
177
+ def test_add_sub_timedeltalike_invalid (self , numeric_idx , other , box ):
178
+ left = tm .box_expected (numeric_idx , box )
179
+ with pytest .raises (TypeError ):
180
+ left + other
181
+ with pytest .raises (TypeError ):
182
+ other + left
183
+ with pytest .raises (TypeError ):
184
+ left - other
185
+ with pytest .raises (TypeError ):
186
+ other - left
187
+
172
188
173
189
# ------------------------------------------------------------------
174
190
# Arithmetic
0 commit comments