@@ -52,7 +52,7 @@ cpdef get_value_at(ndarray arr, object loc, object tz=None):
5252
5353
5454# Don't populate hash tables in monotonic indexes larger than this
55- _SIZE_CUTOFF = 1000000
55+ _SIZE_CUTOFF = 1 _000_000
5656
5757
5858cdef class IndexEngine:
@@ -79,6 +79,8 @@ cdef class IndexEngine:
7979
8080 cpdef get_value(self , ndarray arr, object key, object tz = None ):
8181 """
82+ Parameters
83+ ----------
8284 arr : 1-dimensional ndarray
8385 """
8486 cdef:
@@ -93,6 +95,8 @@ cdef class IndexEngine:
9395
9496 cpdef set_value(self , ndarray arr, object key, object value):
9597 """
98+ Parameters
99+ ----------
96100 arr : 1-dimensional ndarray
97101 """
98102 cdef:
@@ -283,11 +287,12 @@ cdef class IndexEngine:
283287 return self .mapping.lookup(values)
284288
285289 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+ """
291296 cdef:
292297 ndarray values, x
293298 ndarray[int64_t] result, missing
@@ -302,8 +307,8 @@ cdef class IndexEngine:
302307 stargets = set (targets)
303308 n = len (values)
304309 n_t = len (targets)
305- if n > 10000 :
306- n_alloc = 10000
310+ if n > 10 _000 :
311+ n_alloc = 10 _000
307312 else :
308313 n_alloc = n
309314
@@ -345,7 +350,7 @@ cdef class IndexEngine:
345350
346351 # realloc if needed
347352 if count >= n_alloc:
348- n_alloc += 10000
353+ n_alloc += 10 _000
349354 result = np.resize(result, n_alloc)
350355
351356 result[count] = j
@@ -355,7 +360,7 @@ cdef class IndexEngine:
355360 else :
356361
357362 if count >= n_alloc:
358- n_alloc += 10000
363+ n_alloc += 10 _000
359364 result = np.resize(result, n_alloc)
360365 result[count] = - 1
361366 count += 1
@@ -393,7 +398,7 @@ cdef Py_ssize_t _bin_search(ndarray values, object val) except -1:
393398
394399cdef class ObjectEngine(IndexEngine):
395400 """
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.
397402 """
398403 cdef _make_hash_table(self , Py_ssize_t n):
399404 return _hash.PyObjectHashTable(n)
@@ -560,7 +565,7 @@ cpdef convert_scalar(ndarray arr, object value):
560565 pass
561566 elif value is None or value != value:
562567 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 "
564569 f" {type(value).__name__}" )
565570
566571 elif arr.descr.type_num == NPY_TIMEDELTA:
@@ -577,17 +582,17 @@ cpdef convert_scalar(ndarray arr, object value):
577582 pass
578583 elif value is None or value != value:
579584 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 "
581586 f" {type(value).__name__}" )
582587
583588 if (issubclass (arr.dtype.type, (np.integer, np.floating, np.complex)) and
584589 not issubclass (arr.dtype.type, np.bool_)):
585590 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" )
587592
588593 if issubclass (arr.dtype.type, (np.integer, np.bool_)):
589594 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" )
591596
592597 return value
593598
@@ -625,13 +630,12 @@ cdef class BaseMultiIndexCodesEngine:
625630 Parameters
626631 ----------
627632 levels : list-like of numpy arrays
628- Levels of the MultiIndex
633+ Levels of the MultiIndex.
629634 labels : list-like of numpy arrays of integer dtype
630- Labels of the MultiIndex
635+ Labels of the MultiIndex.
631636 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.
633638 """
634-
635639 self .levels = levels
636640 self .offsets = offsets
637641
@@ -664,7 +668,6 @@ cdef class BaseMultiIndexCodesEngine:
664668 int_keys : 1-dimensional array of dtype uint64 or object
665669 Integers representing one combination each
666670 """
667-
668671 level_codes = [lev.get_indexer(codes) + 1 for lev, codes
669672 in zip (self .levels, zip (* target))]
670673 return self ._codes_to_ints(np.array(level_codes, dtype = ' uint64' ).T)
0 commit comments