@@ -259,7 +259,7 @@ cdef class IndexEngine:
259
259
self .monotonic_inc = 0
260
260
self .monotonic_dec = 0
261
261
262
- def get_indexer (self , ndarray values ):
262
+ def get_indexer (self , ndarray values ) -> np.ndarray :
263
263
self._ensure_mapping_populated()
264
264
return self.mapping.lookup(values )
265
265
@@ -269,6 +269,11 @@ cdef class IndexEngine:
269
269
return the labels in the same order as the target
270
270
and a missing indexer into the targets (which correspond
271
271
to the -1 indices in the results
272
+
273
+ Returns
274
+ -------
275
+ indexer : np.ndarray[np.intp]
276
+ missing : np.ndarray[np.intp]
272
277
"""
273
278
cdef:
274
279
ndarray values, x
@@ -455,7 +460,7 @@ cdef class DatetimeEngine(Int64Engine):
455
460
# we may get datetime64[ns] or timedelta64[ns], cast these to int64
456
461
return super ().get_indexer_non_unique(targets.view(" i8" ))
457
462
458
- def get_indexer (self , ndarray values ):
463
+ def get_indexer (self , ndarray values ) -> np.ndarray :
459
464
self._ensure_mapping_populated()
460
465
if values.dtype != self._get_box_dtype():
461
466
return np.repeat(- 1 , len (values)).astype(np.intp)
@@ -572,17 +577,17 @@ cdef class BaseMultiIndexCodesEngine:
572
577
# integers representing labels: we will use its get_loc and get_indexer
573
578
self ._base.__init__ (self , lambda : lab_ints, len (lab_ints))
574
579
575
- def _codes_to_ints (self , codes ):
580
+ def _codes_to_ints (self , ndarray[uint64_t] codes ) -> np.ndarray :
576
581
raise NotImplementedError("Implemented by subclass")
577
582
578
- def _extract_level_codes (self , object target ):
583
+ def _extract_level_codes(self , ndarray[ object] target ) -> np.ndarray :
579
584
"""
580
585
Map the requested list of (tuple ) keys to their integer representations
581
586
for searching in the underlying integer index.
582
587
583
588
Parameters
584
589
----------
585
- target : list-like of keys
590
+ target : ndarray[object]
586
591
Each key is a tuple , with a label for each level of the index.
587
592
588
593
Returns
@@ -607,7 +612,7 @@ cdef class BaseMultiIndexCodesEngine:
607
612
608
613
Returns
609
614
-------
610
- np.ndarray[int64_t , ndim = 1 ] of the indexer of `target` into
615
+ np.ndarray[intp_t , ndim = 1 ] of the indexer of `target` into
611
616
`self.values`
612
617
"""
613
618
lab_ints = self ._extract_level_codes(target)
@@ -635,15 +640,15 @@ cdef class BaseMultiIndexCodesEngine:
635
640
the same as the length of all tuples in `values`
636
641
values : ndarray[object] of tuples
637
642
must be sorted and all have the same length. Should be the set of
638
- the MultiIndex's values. Needed only if `method` is not None
643
+ the MultiIndex's values.
639
644
method: string
640
645
"backfill" or "pad"
641
646
limit: int or None
642
647
if provided , limit the number of fills to this value
643
648
644
649
Returns
645
650
-------
646
- np.ndarray[int64_t , ndim = 1 ] of the indexer of `target` into `values`,
651
+ np.ndarray[intp_t , ndim = 1 ] of the indexer of `target` into `values`,
647
652
filled with the `method` (and optionally `limit`) specified
648
653
"""
649
654
assert method in ("backfill", "pad")
@@ -714,9 +719,7 @@ cdef class BaseMultiIndexCodesEngine:
714
719
715
720
return self ._base.get_loc(self , lab_int)
716
721
717
- def get_indexer_non_unique (self , ndarray target ):
718
- # This needs to be overridden just because the default one works on
719
- # target._values, and target can be itself a MultiIndex.
722
+ def get_indexer_non_unique (self , ndarray[object] target ):
720
723
721
724
lab_ints = self ._extract_level_codes(target)
722
725
indexer = self ._base.get_indexer_non_unique(self , lab_ints)
0 commit comments