@@ -480,8 +480,7 @@ def _validate_fill_value(self, fill_value):
480
480
fill_value = self ._validate_scalar (fill_value , msg )
481
481
except TypeError as err :
482
482
raise ValueError (msg ) from err
483
- rv = self ._unbox (fill_value )
484
- return self ._rebox_native (rv )
483
+ return self ._unbox (fill_value )
485
484
486
485
def _validate_shift_value (self , fill_value ):
487
486
# TODO(2.0): once this deprecation is enforced, use _validate_fill_value
@@ -508,8 +507,7 @@ def _validate_shift_value(self, fill_value):
508
507
)
509
508
fill_value = new_fill
510
509
511
- rv = self ._unbox (fill_value )
512
- return self ._rebox_native (rv )
510
+ return self ._unbox (fill_value )
513
511
514
512
def _validate_scalar (self , value , msg : Optional [str ] = None ):
515
513
"""
@@ -591,8 +589,7 @@ def _validate_searchsorted_value(self, value):
591
589
else :
592
590
value = self ._validate_listlike (value )
593
591
594
- rv = self ._unbox (value )
595
- return self ._rebox_native (rv )
592
+ return self ._unbox (value )
596
593
597
594
def _validate_setitem_value (self , value ):
598
595
msg = (
@@ -604,15 +601,13 @@ def _validate_setitem_value(self, value):
604
601
else :
605
602
value = self ._validate_scalar (value , msg )
606
603
607
- rv = self ._unbox (value , setitem = True )
608
- return self ._rebox_native (rv )
604
+ return self ._unbox (value , setitem = True )
609
605
610
606
def _validate_insert_value (self , value ):
611
607
msg = f"cannot insert { type (self ).__name__ } with incompatible label"
612
608
value = self ._validate_scalar (value , msg )
613
609
614
- rv = self ._unbox (value , setitem = True )
615
- return self ._rebox_native (rv )
610
+ return self ._unbox (value , setitem = True )
616
611
617
612
def _validate_where_value (self , other ):
618
613
msg = f"Where requires matching dtype, not { type (other )} "
@@ -621,19 +616,21 @@ def _validate_where_value(self, other):
621
616
else :
622
617
other = self ._validate_listlike (other )
623
618
624
- rv = self ._unbox (other , setitem = True )
625
- return self ._rebox_native (rv )
619
+ return self ._unbox (other , setitem = True )
626
620
627
- def _unbox (self , other , setitem : bool = False ) -> Union [np .int64 , np .ndarray ]:
621
+ def _unbox (
622
+ self , other , setitem : bool = False
623
+ ) -> Union [np .int64 , np .datetime64 , np .timedelta64 , np .ndarray ]:
628
624
"""
629
625
Unbox either a scalar with _unbox_scalar or an instance of our own type.
630
626
"""
631
627
if lib .is_scalar (other ):
632
628
other = self ._unbox_scalar (other , setitem = setitem )
629
+ other = self ._rebox_native (other )
633
630
else :
634
631
# same type as self
635
632
self ._check_compatible_with (other , setitem = setitem )
636
- other = other .view ( "i8" )
633
+ other = other ._ndarray
637
634
return other
638
635
639
636
# ------------------------------------------------------------------
@@ -862,8 +859,8 @@ def _cmp_method(self, other, op):
862
859
)
863
860
return result
864
861
865
- other_i8 = self ._unbox (other )
866
- result = op (self .asi8 , other_i8 )
862
+ other_vals = self ._unbox (other )
863
+ result = op (self ._ndarray , other_vals )
867
864
868
865
o_mask = isna (other )
869
866
if self ._hasnans | np .any (o_mask ):
0 commit comments