@@ -603,35 +603,34 @@ cdef class BaseMultiIndexCodesEngine:
603
603
def _codes_to_ints (self , ndarray[uint64_t] codes ) -> np.ndarray:
604
604
raise NotImplementedError("Implemented by subclass")
605
605
606
- def _extract_level_codes(self , ndarray[object] target ) -> np.ndarray:
606
+ def _extract_level_codes(self , target ) -> np.ndarray:
607
607
"""
608
608
Map the requested list of (tuple ) keys to their integer representations
609
609
for searching in the underlying integer index.
610
610
611
611
Parameters
612
612
----------
613
- target : ndarray[object]
614
- Each key is a tuple , with a label for each level of the index.
613
+ target : MultiIndex
615
614
616
615
Returns
617
616
------
618
617
int_keys : 1-dimensional array of dtype uint64 or object
619
618
Integers representing one combination each
620
619
"""
620
+ zt = [target._get_level_values(i) for i in range (target.nlevels)]
621
621
level_codes = [lev.get_indexer(codes) + 1 for lev, codes
622
- in zip (self .levels, zip ( * target) )]
622
+ in zip (self .levels, zt )]
623
623
return self._codes_to_ints(np.array(level_codes , dtype = ' uint64' ).T )
624
624
625
- def get_indexer(self , ndarray[object] target ) -> np.ndarray:
625
+ def get_indexer(self , target ) -> np.ndarray:
626
626
"""
627
627
Returns an array giving the positions of each value of `target` in
628
628
`self.values`, where -1 represents a value in `target` which does not
629
629
appear in `self.values`
630
630
631
631
Parameters
632
632
----------
633
- target : ndarray[object]
634
- Each key is a tuple , with a label for each level of the index
633
+ target : MultiIndex
635
634
636
635
Returns
637
636
-------
@@ -742,8 +741,8 @@ cdef class BaseMultiIndexCodesEngine:
742
741
743
742
return self ._base.get_loc(self , lab_int)
744
743
745
- def get_indexer_non_unique (self , ndarray[object] target ):
746
-
744
+ def get_indexer_non_unique (self , target ):
745
+ # target: MultiIndex
747
746
lab_ints = self ._extract_level_codes(target)
748
747
indexer = self ._base.get_indexer_non_unique(self , lab_ints)
749
748
0 commit comments