@@ -303,22 +303,22 @@ cdef class HashTable:
303
303
304
304
{{py:
305
305
306
- # name, dtype, float_group
307
- dtypes = [('Float64', 'float64', True),
308
- ('UInt64', 'uint64', False),
309
- ('Int64', 'int64', False),
310
- ('Float32', 'float32', True),
311
- ('UInt32', 'uint32', False),
312
- ('Int32', 'int32', False),
313
- ('UInt16', 'uint16', False),
314
- ('Int16', 'int16', False),
315
- ('UInt8', 'uint8', False),
316
- ('Int8', 'int8', False)]
306
+ # name, dtype, c_type, float_group
307
+ dtypes = [('Float64', 'float64', 'float64_t', True),
308
+ ('UInt64', 'uint64', 'uint64_t', False),
309
+ ('Int64', 'int64', 'int64_t', False),
310
+ ('Float32', 'float32', 'float32_t', True),
311
+ ('UInt32', 'uint32', 'uint32_t', False),
312
+ ('Int32', 'int32', 'int32_t', False),
313
+ ('UInt16', 'uint16', 'uint16_t', False),
314
+ ('Int16', 'int16', 'int16_t', False),
315
+ ('UInt8', 'uint8', 'uint8_t', False),
316
+ ('Int8', 'int8', 'int8_t', False)]
317
317
318
318
}}
319
319
320
320
321
- {{for name, dtype, float_group in dtypes}}
321
+ {{for name, dtype, c_type, float_group in dtypes}}
322
322
323
323
cdef class {{name}}HashTable(HashTable):
324
324
@@ -371,11 +371,11 @@ cdef class {{name}}HashTable(HashTable):
371
371
raise KeyError(key)
372
372
373
373
@cython.boundscheck(False)
374
- def map(self, const {{dtype}}_t [:] keys, const int64_t[:] values):
374
+ def map(self, const {{c_type}} [:] keys, const int64_t[:] values):
375
375
cdef:
376
376
Py_ssize_t i, n = len(values)
377
377
int ret = 0
378
- {{dtype}}_t key
378
+ {{c_type}} key
379
379
khiter_t k
380
380
381
381
with nogil:
@@ -385,11 +385,11 @@ cdef class {{name}}HashTable(HashTable):
385
385
self.table.vals[k] = <Py_ssize_t>values[i]
386
386
387
387
@cython.boundscheck(False)
388
- def map_locations(self, const {{dtype}}_t [:] values):
388
+ def map_locations(self, const {{c_type}} [:] values):
389
389
cdef:
390
390
Py_ssize_t i, n = len(values)
391
391
int ret = 0
392
- {{dtype}}_t val
392
+ {{c_type}} val
393
393
khiter_t k
394
394
395
395
with nogil:
@@ -399,11 +399,11 @@ cdef class {{name}}HashTable(HashTable):
399
399
self.table.vals[k] = i
400
400
401
401
@cython.boundscheck(False)
402
- def lookup(self, const {{dtype}}_t [:] values):
402
+ def lookup(self, const {{c_type}} [:] values):
403
403
cdef:
404
404
Py_ssize_t i, n = len(values)
405
405
int ret = 0
406
- {{dtype}}_t val
406
+ {{c_type}} val
407
407
khiter_t k
408
408
intp_t[:] locs = np.empty(n, dtype=np.intp)
409
409
@@ -420,7 +420,7 @@ cdef class {{name}}HashTable(HashTable):
420
420
421
421
@cython.boundscheck(False)
422
422
@cython.wraparound(False)
423
- def _unique(self, const {{dtype}}_t [:] values, {{name}}Vector uniques,
423
+ def _unique(self, const {{c_type}} [:] values, {{name}}Vector uniques,
424
424
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
425
425
object na_value=None, bint ignore_na=False,
426
426
object mask=None, bint return_inverse=False):
@@ -465,7 +465,7 @@ cdef class {{name}}HashTable(HashTable):
465
465
Py_ssize_t i, idx, count = count_prior, n = len(values)
466
466
int64_t[:] labels
467
467
int ret = 0
468
- {{dtype}}_t val, na_value2
468
+ {{c_type}} val, na_value2
469
469
khiter_t k
470
470
{{name}}VectorData *ud
471
471
bint use_na_value, use_mask
@@ -538,7 +538,7 @@ cdef class {{name}}HashTable(HashTable):
538
538
return uniques.to_array(), np.asarray(labels)
539
539
return uniques.to_array()
540
540
541
- def unique(self, const {{dtype}}_t [:] values, bint return_inverse=False):
541
+ def unique(self, const {{c_type}} [:] values, bint return_inverse=False):
542
542
"""
543
543
Calculate unique values and labels (no sorting!)
544
544
@@ -561,7 +561,7 @@ cdef class {{name}}HashTable(HashTable):
561
561
return self._unique(values, uniques, ignore_na=False,
562
562
return_inverse=return_inverse)
563
563
564
- def factorize(self, const {{dtype}}_t [:] values, Py_ssize_t na_sentinel=-1,
564
+ def factorize(self, const {{c_type}} [:] values, Py_ssize_t na_sentinel=-1,
565
565
object na_value=None, object mask=None):
566
566
"""
567
567
Calculate unique values and labels (no sorting!)
@@ -606,13 +606,13 @@ cdef class {{name}}HashTable(HashTable):
606
606
return labels
607
607
608
608
@cython.boundscheck(False)
609
- def get_labels_groupby(self, const {{dtype}}_t [:] values):
609
+ def get_labels_groupby(self, const {{c_type}} [:] values):
610
610
cdef:
611
611
Py_ssize_t i, n = len(values)
612
612
intp_t[:] labels
613
613
Py_ssize_t idx, count = 0
614
614
int ret = 0
615
- {{dtype}}_t val
615
+ {{c_type}} val
616
616
khiter_t k
617
617
{{name}}Vector uniques = {{name}}Vector()
618
618
{{name}}VectorData *ud
0 commit comments