11
11
starmap ,
12
12
)
13
13
import operator
14
- import warnings
15
14
16
15
import numpy as np
17
16
import pytest
@@ -1166,6 +1165,7 @@ def test_dt64arr_add_sub_parr(
1166
1165
)
1167
1166
assert_invalid_addsub_type (dtarr , parr , msg )
1168
1167
1168
+ @pytest .mark .filterwarnings ("ignore::pandas.errors.PerformanceWarning" )
1169
1169
def test_dt64arr_addsub_time_objects_raises (self , box_with_array , tz_naive_fixture ):
1170
1170
# https://github.com/pandas-dev/pandas/issues/10329
1171
1171
@@ -1183,14 +1183,10 @@ def test_dt64arr_addsub_time_objects_raises(self, box_with_array, tz_naive_fixtu
1183
1183
"cannot subtract DatetimeArray from ndarray" ,
1184
1184
]
1185
1185
)
1186
-
1187
- with warnings .catch_warnings (record = True ):
1188
- # pandas.errors.PerformanceWarning: Non-vectorized DateOffset being
1189
- # applied to Series or DatetimeIndex
1190
- # we aren't testing that here, so ignore.
1191
- warnings .simplefilter ("ignore" , PerformanceWarning )
1192
-
1193
- assert_invalid_addsub_type (obj1 , obj2 , msg = msg )
1186
+ # pandas.errors.PerformanceWarning: Non-vectorized DateOffset being
1187
+ # applied to Series or DatetimeIndex
1188
+ # we aren't testing that here, so ignore.
1189
+ assert_invalid_addsub_type (obj1 , obj2 , msg = msg )
1194
1190
1195
1191
# -------------------------------------------------------------
1196
1192
# Other invalid operations
@@ -1370,6 +1366,7 @@ def test_dt64arr_add_sub_relativedelta_offsets(self, box_with_array):
1370
1366
1371
1367
# TODO: redundant with test_dt64arr_add_sub_DateOffset? that includes
1372
1368
# tz-aware cases which this does not
1369
+ @pytest .mark .filterwarnings ("ignore::pandas.errors.PerformanceWarning" )
1373
1370
@pytest .mark .parametrize (
1374
1371
"cls_and_kwargs" ,
1375
1372
[
@@ -1458,28 +1455,26 @@ def test_dt64arr_add_sub_DateOffsets(
1458
1455
1459
1456
offset_cls = getattr (pd .offsets , cls_name )
1460
1457
1461
- with warnings .catch_warnings (record = True ):
1462
- # pandas.errors.PerformanceWarning: Non-vectorized DateOffset being
1463
- # applied to Series or DatetimeIndex
1464
- # we aren't testing that here, so ignore.
1465
- warnings .simplefilter ("ignore" , PerformanceWarning )
1458
+ # pandas.errors.PerformanceWarning: Non-vectorized DateOffset being
1459
+ # applied to Series or DatetimeIndex
1460
+ # we aren't testing that here, so ignore.
1466
1461
1467
- offset = offset_cls (n , normalize = normalize , ** kwargs )
1462
+ offset = offset_cls (n , normalize = normalize , ** kwargs )
1468
1463
1469
- expected = DatetimeIndex ([x + offset for x in vec_items ])
1470
- expected = tm .box_expected (expected , box_with_array )
1471
- tm .assert_equal (expected , vec + offset )
1464
+ expected = DatetimeIndex ([x + offset for x in vec_items ])
1465
+ expected = tm .box_expected (expected , box_with_array )
1466
+ tm .assert_equal (expected , vec + offset )
1472
1467
1473
- expected = DatetimeIndex ([x - offset for x in vec_items ])
1474
- expected = tm .box_expected (expected , box_with_array )
1475
- tm .assert_equal (expected , vec - offset )
1468
+ expected = DatetimeIndex ([x - offset for x in vec_items ])
1469
+ expected = tm .box_expected (expected , box_with_array )
1470
+ tm .assert_equal (expected , vec - offset )
1476
1471
1477
- expected = DatetimeIndex ([offset + x for x in vec_items ])
1478
- expected = tm .box_expected (expected , box_with_array )
1479
- tm .assert_equal (expected , offset + vec )
1480
- msg = "(bad|unsupported) operand type for unary"
1481
- with pytest .raises (TypeError , match = msg ):
1482
- offset - vec
1472
+ expected = DatetimeIndex ([offset + x for x in vec_items ])
1473
+ expected = tm .box_expected (expected , box_with_array )
1474
+ tm .assert_equal (expected , offset + vec )
1475
+ msg = "(bad|unsupported) operand type for unary"
1476
+ with pytest .raises (TypeError , match = msg ):
1477
+ offset - vec
1483
1478
1484
1479
def test_dt64arr_add_sub_DateOffset (self , box_with_array ):
1485
1480
# GH#10699
0 commit comments