@@ -84,7 +84,7 @@ cdef class IndexEngine:
84
84
if self .over_size_threshold and self .is_monotonic_increasing:
85
85
if not self .is_unique:
86
86
return self ._get_loc_duplicates(val)
87
- values = self ._get_index_values()
87
+ values = self .values
88
88
89
89
self ._check_type(val)
90
90
try :
@@ -116,7 +116,7 @@ cdef class IndexEngine:
116
116
Py_ssize_t diff
117
117
118
118
if self .is_monotonic_increasing:
119
- values = self ._get_index_values()
119
+ values = self .values
120
120
try :
121
121
left = values.searchsorted(val, side = ' left' )
122
122
right = values.searchsorted(val, side = ' right' )
@@ -139,7 +139,7 @@ cdef class IndexEngine:
139
139
cdef:
140
140
ndarray[uint8_t, ndim= 1 , cast= True ] indexer
141
141
142
- indexer = self ._get_index_values() == val
142
+ indexer = self .values == val
143
143
return self ._unpack_bool_indexer(indexer, val)
144
144
145
145
cdef _unpack_bool_indexer(self ,
@@ -199,7 +199,7 @@ cdef class IndexEngine:
199
199
cdef:
200
200
bint is_unique
201
201
try :
202
- values = self ._get_index_values()
202
+ values = self .values
203
203
self .monotonic_inc, self .monotonic_dec, is_unique = \
204
204
self ._call_monotonic(values)
205
205
except TypeError :
@@ -214,17 +214,14 @@ cdef class IndexEngine:
214
214
self .unique = 1
215
215
self .need_unique_check = 0
216
216
217
- cdef ndarray _get_index_values(self ):
218
- return self .values
219
-
220
217
cdef _call_monotonic(self , values):
221
218
return algos.is_monotonic(values, timelike = False )
222
219
223
220
def get_backfill_indexer (self , other: np.ndarray , limit = None ) -> np.ndarray:
224
- return algos.backfill(self._get_index_values() , other , limit = limit)
221
+ return algos.backfill(self.values , other , limit = limit)
225
222
226
223
def get_pad_indexer(self , other: np.ndarray , limit = None ) -> np.ndarray:
227
- return algos.pad(self._get_index_values() , other , limit = limit)
224
+ return algos.pad(self.values , other , limit = limit)
228
225
229
226
cdef _make_hash_table(self , Py_ssize_t n ):
230
227
raise NotImplementedError
@@ -243,7 +240,7 @@ cdef class IndexEngine:
243
240
244
241
if not self .is_mapping_populated:
245
242
246
- values = self ._get_index_values()
243
+ values = self .values
247
244
self .mapping = self ._make_hash_table(len (values))
248
245
self ._call_map_locations(values)
249
246
@@ -291,7 +288,7 @@ cdef class IndexEngine:
291
288
bint d_has_nan = False , stargets_has_nan = False , need_nan_check = True
292
289
293
290
self ._ensure_mapping_populated()
294
- values = np.array( self ._get_index_values(), copy = False )
291
+ values = self .values
295
292
stargets = set (targets)
296
293
297
294
n = len (values)
@@ -411,9 +408,6 @@ cdef class ObjectEngine(IndexEngine):
411
408
412
409
cdef class DatetimeEngine(Int64Engine):
413
410
414
- cdef str _get_box_dtype(self ):
415
- return ' M8[ns]'
416
-
417
411
cdef int64_t _unbox_scalar(self , scalar) except ? - 1 :
418
412
# NB: caller is responsible for ensuring tzawareness compat
419
413
# before we get here
@@ -431,16 +425,13 @@ cdef class DatetimeEngine(Int64Engine):
431
425
if self.over_size_threshold and self.is_monotonic_increasing:
432
426
if not self.is_unique:
433
427
return self._get_loc_duplicates(conv )
434
- values = self ._get_index_values()
428
+ values = self .values
435
429
loc = values.searchsorted(conv, side = ' left' )
436
430
return values[loc] == conv
437
431
438
432
self._ensure_mapping_populated()
439
433
return conv in self.mapping
440
434
441
- cdef ndarray _get_index_values(self ):
442
- return self .values.view(' i8' )
443
-
444
435
cdef _call_monotonic(self , values ):
445
436
return algos.is_monotonic(values, timelike = True )
446
437
@@ -462,7 +453,7 @@ cdef class DatetimeEngine(Int64Engine):
462
453
if self .over_size_threshold and self .is_monotonic_increasing:
463
454
if not self .is_unique:
464
455
return self ._get_loc_duplicates(conv)
465
- values = self ._get_index_values()
456
+ values = self .values
466
457
467
458
loc = values.searchsorted(conv, side = ' left' )
468
459
@@ -479,35 +470,9 @@ cdef class DatetimeEngine(Int64Engine):
479
470
except KeyError :
480
471
raise KeyError (val)
481
472
482
- def get_indexer_non_unique (self , ndarray targets ):
483
- # we may get datetime64[ns] or timedelta64[ns], cast these to int64
484
- return super ().get_indexer_non_unique(targets.view(" i8" ))
485
-
486
- def get_indexer (self , ndarray values ) -> np.ndarray:
487
- self._ensure_mapping_populated()
488
- if values.dtype != self._get_box_dtype():
489
- return np.repeat(- 1 , len (values)).astype(np.intp)
490
- values = np.asarray(values).view(' i8' )
491
- return self .mapping.lookup(values)
492
-
493
- def get_pad_indexer (self , other: np.ndarray , limit = None ) -> np.ndarray:
494
- if other.dtype != self._get_box_dtype():
495
- return np.repeat(- 1 , len (other)).astype(np.intp)
496
- other = np.asarray(other).view(' i8' )
497
- return algos.pad(self ._get_index_values(), other, limit = limit)
498
-
499
- def get_backfill_indexer (self , other: np.ndarray , limit = None ) -> np.ndarray:
500
- if other.dtype != self._get_box_dtype():
501
- return np.repeat(- 1 , len (other)).astype(np.intp)
502
- other = np.asarray(other).view(' i8' )
503
- return algos.backfill(self ._get_index_values(), other, limit = limit)
504
-
505
473
506
474
cdef class TimedeltaEngine(DatetimeEngine):
507
475
508
- cdef str _get_box_dtype(self ):
509
- return ' m8[ns]'
510
-
511
476
cdef int64_t _unbox_scalar(self , scalar) except ? - 1 :
512
477
if not (isinstance (scalar, _Timedelta) or scalar is NaT):
513
478
raise TypeError (scalar)
0 commit comments