@@ -443,6 +443,20 @@ def test_sub_isub(self):
443
443
rng -= 1
444
444
tm .assert_index_equal (rng , expected )
445
445
446
+ def test_sub_period (self ):
447
+ # GH 13078
448
+ # not supported, check TypeError
449
+ p = pd .Period ('2011-01-01' , freq = 'D' )
450
+
451
+ for freq in [None , 'D' ]:
452
+ idx = pd .DatetimeIndex (['2011-01-01' , '2011-01-02' ], freq = freq )
453
+
454
+ with tm .assertRaises (TypeError ):
455
+ idx - p
456
+
457
+ with tm .assertRaises (TypeError ):
458
+ p - idx
459
+
446
460
def test_value_counts_unique (self ):
447
461
# GH 7735
448
462
for tz in [None , 'UTC' , 'Asia/Tokyo' , 'US/Eastern' ]:
@@ -1157,6 +1171,20 @@ def test_dti_tdi_numeric_ops(self):
1157
1171
expected = DatetimeIndex (['20121231' , pd .NaT , '20130101' ])
1158
1172
tm .assert_index_equal (result , expected )
1159
1173
1174
+ def test_sub_period (self ):
1175
+ # GH 13078
1176
+ # not supported, check TypeError
1177
+ p = pd .Period ('2011-01-01' , freq = 'D' )
1178
+
1179
+ for freq in [None , 'H' ]:
1180
+ idx = pd .TimedeltaIndex (['1 hours' , '2 hours' ], freq = freq )
1181
+
1182
+ with tm .assertRaises (TypeError ):
1183
+ idx - p
1184
+
1185
+ with tm .assertRaises (TypeError ):
1186
+ p - idx
1187
+
1160
1188
def test_addition_ops (self ):
1161
1189
1162
1190
# with datetimes/timedelta and tdi/dti
0 commit comments