@@ -428,7 +428,7 @@ def split_and_operate(self, func, *args, **kwargs) -> list[Block]:
428
428
# Up/Down-casting
429
429
430
430
@final
431
- def coerce_to_target_dtype (self , other , warn_on_upcast : bool = False ) -> Block :
431
+ def coerce_to_target_dtype (self , other , raise_on_upcast : bool = False ) -> Block :
432
432
"""
433
433
coerce the current block to a dtype compat for other
434
434
we will return a block, possibly object, and not raise
@@ -455,17 +455,17 @@ def coerce_to_target_dtype(self, other, warn_on_upcast: bool = False) -> Block:
455
455
isinstance (other , (np .datetime64 , np .timedelta64 )) and np .isnat (other )
456
456
)
457
457
):
458
- warn_on_upcast = False
458
+ raise_on_upcast = False
459
459
elif (
460
460
isinstance (other , np .ndarray )
461
461
and other .ndim == 1
462
462
and is_integer_dtype (self .values .dtype )
463
463
and is_float_dtype (other .dtype )
464
464
and lib .has_only_ints_or_nan (other )
465
465
):
466
- warn_on_upcast = False
466
+ raise_on_upcast = False
467
467
468
- if warn_on_upcast :
468
+ if raise_on_upcast :
469
469
raise TypeError (f"Invalid value '{ other } ' for dtype '{ self .values .dtype } '" )
470
470
if self .values .dtype == new_dtype :
471
471
raise AssertionError (
@@ -1098,7 +1098,7 @@ def setitem(self, indexer, value) -> Block:
1098
1098
casted = np_can_hold_element (values .dtype , value )
1099
1099
except LossySetitemError :
1100
1100
# current dtype cannot store value, coerce to common dtype
1101
- nb = self .coerce_to_target_dtype (value , warn_on_upcast = True )
1101
+ nb = self .coerce_to_target_dtype (value , raise_on_upcast = True )
1102
1102
return nb .setitem (indexer , value )
1103
1103
else :
1104
1104
if self .dtype == _dtype_obj :
@@ -1169,7 +1169,7 @@ def putmask(self, mask, new) -> list[Block]:
1169
1169
if not is_list_like (new ):
1170
1170
# using just new[indexer] can't save us the need to cast
1171
1171
return self .coerce_to_target_dtype (
1172
- new , warn_on_upcast = True
1172
+ new , raise_on_upcast = True
1173
1173
).putmask (mask , new )
1174
1174
else :
1175
1175
indexer = mask .nonzero ()[0 ]
@@ -1630,11 +1630,11 @@ def setitem(self, indexer, value):
1630
1630
except (ValueError , TypeError ):
1631
1631
if isinstance (self .dtype , IntervalDtype ):
1632
1632
# see TestSetitemFloatIntervalWithIntIntervalValues
1633
- nb = self .coerce_to_target_dtype (orig_value , warn_on_upcast = True )
1633
+ nb = self .coerce_to_target_dtype (orig_value , raise_on_upcast = True )
1634
1634
return nb .setitem (orig_indexer , orig_value )
1635
1635
1636
1636
elif isinstance (self , NDArrayBackedExtensionBlock ):
1637
- nb = self .coerce_to_target_dtype (orig_value , warn_on_upcast = True )
1637
+ nb = self .coerce_to_target_dtype (orig_value , raise_on_upcast = True )
1638
1638
return nb .setitem (orig_indexer , orig_value )
1639
1639
1640
1640
else :
@@ -1730,13 +1730,13 @@ def putmask(self, mask, new) -> list[Block]:
1730
1730
if isinstance (self .dtype , IntervalDtype ):
1731
1731
# Discussion about what we want to support in the general
1732
1732
# case GH#39584
1733
- blk = self .coerce_to_target_dtype (orig_new , warn_on_upcast = True )
1733
+ blk = self .coerce_to_target_dtype (orig_new , raise_on_upcast = True )
1734
1734
return blk .putmask (orig_mask , orig_new )
1735
1735
1736
1736
elif isinstance (self , NDArrayBackedExtensionBlock ):
1737
1737
# NB: not (yet) the same as
1738
1738
# isinstance(values, NDArrayBackedExtensionArray)
1739
- blk = self .coerce_to_target_dtype (orig_new , warn_on_upcast = True )
1739
+ blk = self .coerce_to_target_dtype (orig_new , raise_on_upcast = True )
1740
1740
return blk .putmask (orig_mask , orig_new )
1741
1741
1742
1742
else :
0 commit comments