@@ -52,7 +52,7 @@ cpdef get_value_at(ndarray arr, object loc, object tz=None):
52
52
53
53
54
54
# Don't populate hash tables in monotonic indexes larger than this
55
- _SIZE_CUTOFF = 1000000
55
+ _SIZE_CUTOFF = 1 _000_000
56
56
57
57
58
58
cdef class IndexEngine:
@@ -79,6 +79,8 @@ cdef class IndexEngine:
79
79
80
80
cpdef get_value(self , ndarray arr, object key, object tz = None ):
81
81
"""
82
+ Parameters
83
+ ----------
82
84
arr : 1-dimensional ndarray
83
85
"""
84
86
cdef:
@@ -93,6 +95,8 @@ cdef class IndexEngine:
93
95
94
96
cpdef set_value(self , ndarray arr, object key, object value):
95
97
"""
98
+ Parameters
99
+ ----------
96
100
arr : 1-dimensional ndarray
97
101
"""
98
102
cdef:
@@ -283,11 +287,12 @@ cdef class IndexEngine:
283
287
return self .mapping.lookup(values)
284
288
285
289
def get_indexer_non_unique (self , targets ):
286
- """ return an indexer suitable for takng from a non unique index
287
- return the labels in the same order ast the target
288
- and a missing indexer into the targets (which correspond
289
- to the -1 indices in the results """
290
-
290
+ """
291
+ Return an indexer suitable for takng from a non unique index
292
+ return the labels in the same order ast the target
293
+ and a missing indexer into the targets (which correspond
294
+ to the -1 indices in the results
295
+ """
291
296
cdef:
292
297
ndarray values, x
293
298
ndarray[int64_t] result, missing
@@ -302,8 +307,8 @@ cdef class IndexEngine:
302
307
stargets = set (targets)
303
308
n = len (values)
304
309
n_t = len (targets)
305
- if n > 10000 :
306
- n_alloc = 10000
310
+ if n > 10 _000 :
311
+ n_alloc = 10 _000
307
312
else :
308
313
n_alloc = n
309
314
@@ -345,7 +350,7 @@ cdef class IndexEngine:
345
350
346
351
# realloc if needed
347
352
if count >= n_alloc:
348
- n_alloc += 10000
353
+ n_alloc += 10 _000
349
354
result = np.resize(result, n_alloc)
350
355
351
356
result[count] = j
@@ -355,7 +360,7 @@ cdef class IndexEngine:
355
360
else :
356
361
357
362
if count >= n_alloc:
358
- n_alloc += 10000
363
+ n_alloc += 10 _000
359
364
result = np.resize(result, n_alloc)
360
365
result[count] = - 1
361
366
count += 1
@@ -393,7 +398,7 @@ cdef Py_ssize_t _bin_search(ndarray values, object val) except -1:
393
398
394
399
cdef class ObjectEngine(IndexEngine):
395
400
"""
396
- Index Engine for use with object-dtype Index, namely the base class Index
401
+ Index Engine for use with object-dtype Index, namely the base class Index.
397
402
"""
398
403
cdef _make_hash_table(self , Py_ssize_t n):
399
404
return _hash.PyObjectHashTable(n)
@@ -560,7 +565,7 @@ cpdef convert_scalar(ndarray arr, object value):
560
565
pass
561
566
elif value is None or value != value:
562
567
return np.datetime64(" NaT" , " ns" )
563
- raise ValueError (f " cannot set a Timestamp with a non-timestamp "
568
+ raise ValueError (" cannot set a Timestamp with a non-timestamp "
564
569
f" {type(value).__name__}" )
565
570
566
571
elif arr.descr.type_num == NPY_TIMEDELTA:
@@ -577,17 +582,17 @@ cpdef convert_scalar(ndarray arr, object value):
577
582
pass
578
583
elif value is None or value != value:
579
584
return np.timedelta64(" NaT" , " ns" )
580
- raise ValueError (f " cannot set a Timedelta with a non-timedelta "
585
+ raise ValueError (" cannot set a Timedelta with a non-timedelta "
581
586
f" {type(value).__name__}" )
582
587
583
588
if (issubclass (arr.dtype.type, (np.integer, np.floating, np.complex)) and
584
589
not issubclass (arr.dtype.type, np.bool_)):
585
590
if util.is_bool_object(value):
586
- raise ValueError (' Cannot assign bool to float/integer series' )
591
+ raise ValueError (" Cannot assign bool to float/integer series" )
587
592
588
593
if issubclass (arr.dtype.type, (np.integer, np.bool_)):
589
594
if util.is_float_object(value) and value != value:
590
- raise ValueError (' Cannot assign nan to integer series' )
595
+ raise ValueError (" Cannot assign nan to integer series" )
591
596
592
597
return value
593
598
@@ -625,13 +630,12 @@ cdef class BaseMultiIndexCodesEngine:
625
630
Parameters
626
631
----------
627
632
levels : list-like of numpy arrays
628
- Levels of the MultiIndex
633
+ Levels of the MultiIndex.
629
634
labels : list-like of numpy arrays of integer dtype
630
- Labels of the MultiIndex
635
+ Labels of the MultiIndex.
631
636
offsets : numpy array of uint64 dtype
632
- Pre-calculated offsets, one for each level of the index
637
+ Pre-calculated offsets, one for each level of the index.
633
638
"""
634
-
635
639
self .levels = levels
636
640
self .offsets = offsets
637
641
@@ -664,7 +668,6 @@ cdef class BaseMultiIndexCodesEngine:
664
668
int_keys : 1-dimensional array of dtype uint64 or object
665
669
Integers representing one combination each
666
670
"""
667
-
668
671
level_codes = [lev.get_indexer(codes) + 1 for lev, codes
669
672
in zip (self .levels, zip (* target))]
670
673
return self ._codes_to_ints(np.array(level_codes, dtype = ' uint64' ).T)
0 commit comments