@@ -485,25 +485,13 @@ def test_maybe_promote_bytes_with_any(bytes_dtype, any_numpy_dtype_reduced, box)
485
485
fill_dtype = np .dtype (any_numpy_dtype_reduced )
486
486
boxed , box_dtype = box # read from parametrized fixture
487
487
488
- if issubclass (fill_dtype .type , np .bytes_ ):
489
- if not boxed or box_dtype == object :
490
- pytest .xfail ("falsely upcasts to object" )
491
- # takes the opinion that bool dtype has no missing value marker
492
- else :
493
- pytest .xfail ("wrong missing value marker" )
494
- else :
495
- if boxed and box_dtype is None :
496
- pytest .xfail ("does not upcast to object" )
497
-
498
488
# create array of given dtype; casts "1" to correct dtype
499
489
fill_value = np .array ([1 ], dtype = fill_dtype )[0 ]
500
490
501
- # filling bytes with anything but bytes casts to object
502
- expected_dtype = (
503
- dtype if issubclass (fill_dtype .type , np .bytes_ ) else np .dtype (object )
504
- )
491
+ # we never use bytes dtype internally, always promote to object
492
+ expected_dtype = np .dtype (np .object_ )
505
493
exp_val_for_scalar = fill_value
506
- exp_val_for_array = None if issubclass ( fill_dtype . type , np . bytes_ ) else np .nan
494
+ exp_val_for_array = np .nan
507
495
508
496
_check_promote (
509
497
dtype ,
@@ -521,13 +509,7 @@ def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced, bytes_dtype, box)
521
509
fill_dtype = np .dtype (bytes_dtype )
522
510
boxed , box_dtype = box # read from parametrized fixture
523
511
524
- if issubclass (dtype .type , np .bytes_ ):
525
- if not boxed or box_dtype == object :
526
- pytest .xfail ("falsely upcasts to object" )
527
- # takes the opinion that bool dtype has no missing value marker
528
- else :
529
- pytest .xfail ("wrong missing value marker" )
530
- else :
512
+ if not issubclass (dtype .type , np .bytes_ ):
531
513
if (
532
514
boxed
533
515
and (box_dtype == "bytes" or box_dtype is None )
@@ -541,11 +523,11 @@ def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced, bytes_dtype, box)
541
523
# special case for box_dtype (cannot use fixture in parametrization)
542
524
box_dtype = fill_dtype if box_dtype == "bytes" else box_dtype
543
525
544
- # filling bytes with anything but bytes casts to object
545
- expected_dtype = dtype if issubclass ( dtype . type , np .bytes_ ) else np . dtype (object )
526
+ # we never use bytes dtype internally, always promote to object
527
+ expected_dtype = np .dtype (np . object_ )
546
528
# output is not a generic bytes, but corresponds to expected_dtype
547
529
exp_val_for_scalar = np .array ([fill_value ], dtype = expected_dtype )[0 ]
548
- exp_val_for_array = None if issubclass ( dtype . type , np . bytes_ ) else np .nan
530
+ exp_val_for_array = np .nan
549
531
550
532
_check_promote (
551
533
dtype ,
0 commit comments