@@ -423,7 +423,7 @@ cdef class {{name}}HashTable(HashTable):
423
423
raise KeyError(key)
424
424
425
425
@cython.boundscheck(False)
426
- def map(self, const {{c_type}} [:] keys, const int64_t[:] values):
426
+ def map(self, const {{dtype}}_t [:] keys, const int64_t[:] values):
427
427
cdef:
428
428
Py_ssize_t i, n = len(values)
429
429
int ret = 0
@@ -432,12 +432,16 @@ cdef class {{name}}HashTable(HashTable):
432
432
433
433
with nogil:
434
434
for i in range(n):
435
+ {{if complex_group}}
436
+ key = to_{{c_type}}(keys[i])
437
+ {{else}}
435
438
key = keys[i]
439
+ {{endif}}
436
440
k = kh_put_{{dtype}}(self.table, key, &ret)
437
441
self.table.vals[k] = <Py_ssize_t>values[i]
438
442
439
443
@cython.boundscheck(False)
440
- def map_locations(self, const {{c_type}} [:] values):
444
+ def map_locations(self, const {{dtype}}_t [:] values):
441
445
cdef:
442
446
Py_ssize_t i, n = len(values)
443
447
int ret = 0
@@ -446,12 +450,16 @@ cdef class {{name}}HashTable(HashTable):
446
450
447
451
with nogil:
448
452
for i in range(n):
453
+ {{if complex_group}}
454
+ val= to_{{c_type}}(values[i])
455
+ {{else}}
449
456
val = values[i]
457
+ {{endif}}
450
458
k = kh_put_{{dtype}}(self.table, val, &ret)
451
459
self.table.vals[k] = i
452
460
453
461
@cython.boundscheck(False)
454
- def lookup(self, const {{c_type}} [:] values):
462
+ def lookup(self, const {{dtype}}_t [:] values):
455
463
cdef:
456
464
Py_ssize_t i, n = len(values)
457
465
int ret = 0
@@ -461,7 +469,11 @@ cdef class {{name}}HashTable(HashTable):
461
469
462
470
with nogil:
463
471
for i in range(n):
472
+ {{if complex_group}}
473
+ val = to_{{c_type}}(values[i])
474
+ {{else}}
464
475
val = values[i]
476
+ {{endif}}
465
477
k = kh_get_{{dtype}}(self.table, val)
466
478
if k != self.table.n_buckets:
467
479
locs[i] = self.table.vals[k]
@@ -472,7 +484,7 @@ cdef class {{name}}HashTable(HashTable):
472
484
473
485
@cython.boundscheck(False)
474
486
@cython.wraparound(False)
475
- def _unique(self, const {{c_type}} [:] values, {{name}}Vector uniques,
487
+ def _unique(self, const {{dtype}}_t [:] values, {{name}}Vector uniques,
476
488
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
477
489
object na_value=None, bint ignore_na=False,
478
490
object mask=None, bint return_inverse=False):
@@ -552,7 +564,11 @@ cdef class {{name}}HashTable(HashTable):
552
564
553
565
with nogil:
554
566
for i in range(n):
567
+ {{if complex_group}}
568
+ val = to_{{c_type}}(values[i])
569
+ {{else}}
555
570
val = values[i]
571
+ {{endif}}
556
572
557
573
if ignore_na and use_mask:
558
574
if mask_values[i]:
@@ -602,7 +618,7 @@ cdef class {{name}}HashTable(HashTable):
602
618
return uniques.to_array(), np.asarray(labels)
603
619
return uniques.to_array()
604
620
605
- def unique(self, const {{c_type}} [:] values, bint return_inverse=False):
621
+ def unique(self, const {{dtype}}_t [:] values, bint return_inverse=False):
606
622
"""
607
623
Calculate unique values and labels (no sorting!)
608
624
@@ -625,7 +641,7 @@ cdef class {{name}}HashTable(HashTable):
625
641
return self._unique(values, uniques, ignore_na=False,
626
642
return_inverse=return_inverse)
627
643
628
- def factorize(self, const {{c_type}} [:] values, Py_ssize_t na_sentinel=-1,
644
+ def factorize(self, const {{dtype}}_t [:] values, Py_ssize_t na_sentinel=-1,
629
645
object na_value=None, object mask=None):
630
646
"""
631
647
Calculate unique values and labels (no sorting!)
@@ -670,7 +686,7 @@ cdef class {{name}}HashTable(HashTable):
670
686
return labels
671
687
672
688
@cython.boundscheck(False)
673
- def get_labels_groupby(self, const {{c_type}} [:] values):
689
+ def get_labels_groupby(self, const {{dtype}}_t [:] values):
674
690
cdef:
675
691
Py_ssize_t i, n = len(values)
676
692
intp_t[:] labels
@@ -686,7 +702,11 @@ cdef class {{name}}HashTable(HashTable):
686
702
687
703
with nogil:
688
704
for i in range(n):
705
+ {{if complex_group}}
706
+ val = to_{{c_type}}(values[i])
707
+ {{else}}
689
708
val = values[i]
709
+ {{endif}}
690
710
691
711
# specific for groupby
692
712
{{if dtype == 'complex64' or dtype== 'complex128'}}
0 commit comments