@@ -7433,7 +7433,8 @@ def _arith_method(self, other, op):
7433
7433
7434
7434
self , other = self ._align_for_op (other , axis , flex = True , level = None )
7435
7435
7436
- new_data = self ._dispatch_frame_op (other , op , axis = axis )
7436
+ with np .errstate (all = "ignore" ):
7437
+ new_data = self ._dispatch_frame_op (other , op , axis = axis )
7437
7438
return self ._construct_result (new_data )
7438
7439
7439
7440
_logical_method = _arith_method
@@ -7454,15 +7455,18 @@ def _dispatch_frame_op(
7454
7455
Returns
7455
7456
-------
7456
7457
DataFrame
7458
+
7459
+ Notes
7460
+ -----
7461
+ Caller is responsible for setting np.errstate where relevant.
7457
7462
"""
7458
7463
# Get the appropriate array-op to apply to each column/block's values.
7459
7464
array_op = ops .get_array_op (func )
7460
7465
7461
7466
right = lib .item_from_zerodim (right )
7462
7467
if not is_list_like (right ):
7463
7468
# i.e. scalar, faster than checking np.ndim(right) == 0
7464
- with np .errstate (all = "ignore" ):
7465
- bm = self ._mgr .apply (array_op , right = right )
7469
+ bm = self ._mgr .apply (array_op , right = right )
7466
7470
return self ._constructor (bm )
7467
7471
7468
7472
elif isinstance (right , DataFrame ):
@@ -7473,17 +7477,16 @@ def _dispatch_frame_op(
7473
7477
# _frame_arith_method_with_reindex
7474
7478
7475
7479
# TODO operate_blockwise expects a manager of the same type
7476
- with np .errstate (all = "ignore" ):
7477
- bm = self ._mgr .operate_blockwise (
7478
- # error: Argument 1 to "operate_blockwise" of "ArrayManager" has
7479
- # incompatible type "Union[ArrayManager, BlockManager]"; expected
7480
- # "ArrayManager"
7481
- # error: Argument 1 to "operate_blockwise" of "BlockManager" has
7482
- # incompatible type "Union[ArrayManager, BlockManager]"; expected
7483
- # "BlockManager"
7484
- right ._mgr , # type: ignore[arg-type]
7485
- array_op ,
7486
- )
7480
+ bm = self ._mgr .operate_blockwise (
7481
+ # error: Argument 1 to "operate_blockwise" of "ArrayManager" has
7482
+ # incompatible type "Union[ArrayManager, BlockManager]"; expected
7483
+ # "ArrayManager"
7484
+ # error: Argument 1 to "operate_blockwise" of "BlockManager" has
7485
+ # incompatible type "Union[ArrayManager, BlockManager]"; expected
7486
+ # "BlockManager"
7487
+ right ._mgr , # type: ignore[arg-type]
7488
+ array_op ,
7489
+ )
7487
7490
return self ._constructor (bm )
7488
7491
7489
7492
elif isinstance (right , Series ) and axis == 1 :
@@ -7494,18 +7497,16 @@ def _dispatch_frame_op(
7494
7497
# maybe_align_as_frame ensures we do not have an ndarray here
7495
7498
assert not isinstance (right , np .ndarray )
7496
7499
7497
- with np .errstate (all = "ignore" ):
7498
- arrays = [
7499
- array_op (_left , _right )
7500
- for _left , _right in zip (self ._iter_column_arrays (), right )
7501
- ]
7500
+ arrays = [
7501
+ array_op (_left , _right )
7502
+ for _left , _right in zip (self ._iter_column_arrays (), right )
7503
+ ]
7502
7504
7503
7505
elif isinstance (right , Series ):
7504
7506
assert right .index .equals (self .index )
7505
7507
right = right ._values
7506
7508
7507
- with np .errstate (all = "ignore" ):
7508
- arrays = [array_op (left , right ) for left in self ._iter_column_arrays ()]
7509
+ arrays = [array_op (left , right ) for left in self ._iter_column_arrays ()]
7509
7510
7510
7511
else :
7511
7512
raise NotImplementedError (right )
@@ -7784,18 +7785,19 @@ def _flex_arith_method(
7784
7785
)
7785
7786
self , other = self ._align_for_op (other , axis , flex = True , level = level )
7786
7787
7787
- if isinstance (other , DataFrame ):
7788
- # Another DataFrame
7789
- new_data = self ._combine_frame (other , op , fill_value )
7788
+ with np .errstate (all = "ignore" ):
7789
+ if isinstance (other , DataFrame ):
7790
+ # Another DataFrame
7791
+ new_data = self ._combine_frame (other , op , fill_value )
7790
7792
7791
- elif isinstance (other , Series ):
7792
- new_data = self ._dispatch_frame_op (other , op , axis = axis )
7793
- else :
7794
- # in this case we always have `np.ndim(other) == 0`
7795
- if fill_value is not None :
7796
- self = self .fillna (fill_value )
7793
+ elif isinstance (other , Series ):
7794
+ new_data = self ._dispatch_frame_op (other , op , axis = axis )
7795
+ else :
7796
+ # in this case we always have `np.ndim(other) == 0`
7797
+ if fill_value is not None :
7798
+ self = self .fillna (fill_value )
7797
7799
7798
- new_data = self ._dispatch_frame_op (other , op )
7800
+ new_data = self ._dispatch_frame_op (other , op )
7799
7801
7800
7802
return self ._construct_result (new_data )
7801
7803
@@ -8477,8 +8479,7 @@ def update(
8477
8479
that = other [col ]._values
8478
8480
8479
8481
if filter_func is not None :
8480
- with np .errstate (all = "ignore" ):
8481
- mask = ~ filter_func (this ) | isna (that )
8482
+ mask = ~ filter_func (this ) | isna (that )
8482
8483
else :
8483
8484
if errors == "raise" :
8484
8485
mask_this = notna (that )
0 commit comments