@@ -1287,20 +1287,8 @@ def test_add_offset(self):
1287
1287
msg = "Input has different freq|Input cannot be converted to Period"
1288
1288
with pytest .raises (IncompatibleFrequency , match = msg ):
1289
1289
p + o
1290
-
1291
- if isinstance (o , np .timedelta64 ):
1292
- msg = "cannot use operands with types"
1293
- with pytest .raises (TypeError , match = msg ):
1294
- o + p
1295
- else :
1296
- msg = "|" .join (
1297
- [
1298
- "Input has different freq" ,
1299
- "Input cannot be converted to Period" ,
1300
- ]
1301
- )
1302
- with pytest .raises (IncompatibleFrequency , match = msg ):
1303
- o + p
1290
+ with pytest .raises (IncompatibleFrequency , match = msg ):
1291
+ o + p
1304
1292
1305
1293
for freq in ["M" , "2M" , "3M" ]:
1306
1294
p = Period ("2011-03" , freq = freq )
@@ -1329,14 +1317,8 @@ def test_add_offset(self):
1329
1317
1330
1318
with pytest .raises (IncompatibleFrequency , match = msg ):
1331
1319
p + o
1332
-
1333
- if isinstance (o , np .timedelta64 ):
1334
- td_msg = "cannot use operands with types"
1335
- with pytest .raises (TypeError , match = td_msg ):
1336
- o + p
1337
- else :
1338
- with pytest .raises (IncompatibleFrequency , match = msg ):
1339
- o + p
1320
+ with pytest .raises (IncompatibleFrequency , match = msg ):
1321
+ o + p
1340
1322
1341
1323
# freq is Tick
1342
1324
for freq in ["D" , "2D" , "3D" ]:
@@ -1352,14 +1334,11 @@ def test_add_offset(self):
1352
1334
1353
1335
exp = Period ("2011-04-03" , freq = freq )
1354
1336
assert p + np .timedelta64 (2 , "D" ) == exp
1355
- msg = "cannot use operands with types"
1356
- with pytest .raises (TypeError , match = msg ):
1357
- np .timedelta64 (2 , "D" ) + p
1337
+ assert np .timedelta64 (2 , "D" ) + p == exp
1358
1338
1359
1339
exp = Period ("2011-04-02" , freq = freq )
1360
1340
assert p + np .timedelta64 (3600 * 24 , "s" ) == exp
1361
- with pytest .raises (TypeError , match = msg ):
1362
- np .timedelta64 (3600 * 24 , "s" ) + p
1341
+ assert np .timedelta64 (3600 * 24 , "s" ) + p == exp
1363
1342
1364
1343
exp = Period ("2011-03-30" , freq = freq )
1365
1344
assert p + timedelta (- 2 ) == exp
@@ -1385,14 +1364,8 @@ def test_add_offset(self):
1385
1364
]:
1386
1365
with pytest .raises (IncompatibleFrequency , match = msg ):
1387
1366
p + o
1388
-
1389
- if isinstance (o , np .timedelta64 ):
1390
- td_msg = "cannot use operands with types"
1391
- with pytest .raises (TypeError , match = td_msg ):
1392
- o + p
1393
- else :
1394
- with pytest .raises (IncompatibleFrequency , match = msg ):
1395
- o + p
1367
+ with pytest .raises (IncompatibleFrequency , match = msg ):
1368
+ o + p
1396
1369
1397
1370
for freq in ["H" , "2H" , "3H" ]:
1398
1371
p = Period ("2011-04-01 09:00" , freq = freq )
@@ -1408,13 +1381,11 @@ def test_add_offset(self):
1408
1381
msg = "cannot use operands with types"
1409
1382
exp = Period ("2011-04-01 12:00" , freq = freq )
1410
1383
assert p + np .timedelta64 (3 , "h" ) == exp
1411
- with pytest .raises (TypeError , match = msg ):
1412
- np .timedelta64 (3 , "h" ) + p
1384
+ assert np .timedelta64 (3 , "h" ) + p == exp
1413
1385
1414
1386
exp = Period ("2011-04-01 10:00" , freq = freq )
1415
1387
assert p + np .timedelta64 (3600 , "s" ) == exp
1416
- with pytest .raises (TypeError , match = msg ):
1417
- np .timedelta64 (3600 , "s" ) + p
1388
+ assert np .timedelta64 (3600 , "s" ) + p == exp
1418
1389
1419
1390
exp = Period ("2011-04-01 11:00" , freq = freq )
1420
1391
assert p + timedelta (minutes = 120 ) == exp
@@ -1440,14 +1411,8 @@ def test_add_offset(self):
1440
1411
]:
1441
1412
with pytest .raises (IncompatibleFrequency , match = msg ):
1442
1413
p + o
1443
-
1444
- if isinstance (o , np .timedelta64 ):
1445
- td_msg = "cannot use operands with types"
1446
- with pytest .raises (TypeError , match = td_msg ):
1447
- o + p
1448
- else :
1449
- with pytest .raises (IncompatibleFrequency , match = msg ):
1450
- o + p
1414
+ with pytest .raises (IncompatibleFrequency , match = msg ):
1415
+ o + p
1451
1416
1452
1417
def test_sub_offset (self ):
1453
1418
# freq is DateOffset
0 commit comments