@@ -648,22 +648,21 @@ def _get_indexer(
648
648
# returned ndarray is np.intp
649
649
650
650
if isinstance (target , IntervalIndex ):
651
- if not self ._should_compare (target ):
652
- return self ._get_indexer_non_comparable (target , method , unique = True )
653
-
654
651
# non-overlapping -> at most one match per interval in target
655
652
# want exact matches -> need both left/right to match, so defer to
656
653
# left/right get_indexer, compare elementwise, equality -> match
657
654
left_indexer = self .left .get_indexer (target .left )
658
655
right_indexer = self .right .get_indexer (target .right )
659
656
indexer = np .where (left_indexer == right_indexer , left_indexer , - 1 )
660
657
661
- elif not is_object_dtype (target ):
658
+ elif not is_object_dtype (target . dtype ):
662
659
# homogeneous scalar index: use IntervalTree
660
+ # we should always have self._should_partial_index(target) here
663
661
target = self ._maybe_convert_i8 (target )
664
662
indexer = self ._engine .get_indexer (target .values )
665
663
else :
666
664
# heterogeneous scalar index: defer elementwise to get_loc
665
+ # we should always have self._should_partial_index(target) here
667
666
return self ._get_indexer_pointwise (target )[0 ]
668
667
669
668
return ensure_platform_int (indexer )
@@ -673,11 +672,12 @@ def get_indexer_non_unique(self, target: Index) -> tuple[np.ndarray, np.ndarray]
673
672
# both returned ndarrays are np.intp
674
673
target = ensure_index (target )
675
674
676
- if isinstance (target , IntervalIndex ) and not self ._should_compare (target ):
677
- # different closed or incompatible subtype -> no matches
675
+ if not self ._should_compare (target ) and not self ._should_partial_index (target ):
676
+ # e.g. IntervalIndex with different closed or incompatible subtype
677
+ # -> no matches
678
678
return self ._get_indexer_non_comparable (target , None , unique = False )
679
679
680
- elif is_object_dtype (target .dtype ) or isinstance (target , IntervalIndex ):
680
+ elif is_object_dtype (target .dtype ) or not self . _should_partial_index (target ):
681
681
# target might contain intervals: defer elementwise to get_loc
682
682
return self ._get_indexer_pointwise (target )
683
683
0 commit comments