@@ -3376,36 +3376,36 @@ def _putmask_smart(v, m, n):
3376
3376
# will work in the current dtype
3377
3377
try :
3378
3378
nn = n [m ]
3379
-
3379
+ except TypeError :
3380
+ # TypeError: only integer scalar arrays can be converted to a scalar index
3381
+ pass
3382
+ else :
3380
3383
# make sure that we have a nullable type
3381
3384
# if we have nulls
3382
3385
if not _isna_compat (v , nn [0 ]):
3383
- raise ValueError
3384
-
3385
- # we ignore ComplexWarning here
3386
- with warnings .catch_warnings (record = True ):
3387
- warnings .simplefilter ("ignore" , np .ComplexWarning )
3388
- nn_at = nn .astype (v .dtype )
3389
-
3390
- # avoid invalid dtype comparisons
3391
- # between numbers & strings
3392
-
3393
- # only compare integers/floats
3394
- # don't compare integers to datetimelikes
3395
- if not is_numeric_v_string_like (nn , nn_at ) and (
3396
- is_float_dtype (nn .dtype )
3397
- or is_integer_dtype (nn .dtype )
3398
- and is_float_dtype (nn_at .dtype )
3399
- or is_integer_dtype (nn_at .dtype )
3400
- ):
3386
+ pass
3387
+ elif is_numeric_v_string_like (nn , v ):
3388
+ # avoid invalid dtype comparisons
3389
+ # between numbers & strings
3390
+ pass
3391
+ elif not (is_float_dtype (nn .dtype ) or is_integer_dtype (nn .dtype )):
3392
+ # only compare integers/floats
3393
+ pass
3394
+ elif not (is_float_dtype (v .dtype ) or is_integer_dtype (v .dtype )):
3395
+ # only compare integers/floats
3396
+ pass
3397
+ else :
3398
+
3399
+ # we ignore ComplexWarning here
3400
+ with warnings .catch_warnings (record = True ):
3401
+ warnings .simplefilter ("ignore" , np .ComplexWarning )
3402
+ nn_at = nn .astype (v .dtype )
3401
3403
3402
3404
comp = nn == nn_at
3403
3405
if is_list_like (comp ) and comp .all ():
3404
3406
nv = v .copy ()
3405
3407
nv [m ] = nn_at
3406
3408
return nv
3407
- except (ValueError , IndexError , TypeError , OverflowError ):
3408
- pass
3409
3409
3410
3410
n = np .asarray (n )
3411
3411
0 commit comments