Skip to content

Commit 06f7a07

Browse files
committed
adding explicit c_type as preparation for complex, for which c_type will not be dtype_t
1 parent 0b70965 commit 06f7a07

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

pandas/_libs/hashtable_class_helper.pxi.in

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,22 @@ cdef class HashTable:
303303

304304
{{py:
305305

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)]
317317

318318
}}
319319

320320

321-
{{for name, dtype, float_group in dtypes}}
321+
{{for name, dtype, c_type, float_group in dtypes}}
322322

323323
cdef class {{name}}HashTable(HashTable):
324324

@@ -371,11 +371,11 @@ cdef class {{name}}HashTable(HashTable):
371371
raise KeyError(key)
372372

373373
@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):
375375
cdef:
376376
Py_ssize_t i, n = len(values)
377377
int ret = 0
378-
{{dtype}}_t key
378+
{{c_type}} key
379379
khiter_t k
380380

381381
with nogil:
@@ -385,11 +385,11 @@ cdef class {{name}}HashTable(HashTable):
385385
self.table.vals[k] = <Py_ssize_t>values[i]
386386

387387
@cython.boundscheck(False)
388-
def map_locations(self, const {{dtype}}_t[:] values):
388+
def map_locations(self, const {{c_type}}[:] values):
389389
cdef:
390390
Py_ssize_t i, n = len(values)
391391
int ret = 0
392-
{{dtype}}_t val
392+
{{c_type}} val
393393
khiter_t k
394394

395395
with nogil:
@@ -399,11 +399,11 @@ cdef class {{name}}HashTable(HashTable):
399399
self.table.vals[k] = i
400400

401401
@cython.boundscheck(False)
402-
def lookup(self, const {{dtype}}_t[:] values):
402+
def lookup(self, const {{c_type}}[:] values):
403403
cdef:
404404
Py_ssize_t i, n = len(values)
405405
int ret = 0
406-
{{dtype}}_t val
406+
{{c_type}} val
407407
khiter_t k
408408
intp_t[:] locs = np.empty(n, dtype=np.intp)
409409

@@ -420,7 +420,7 @@ cdef class {{name}}HashTable(HashTable):
420420

421421
@cython.boundscheck(False)
422422
@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,
424424
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
425425
object na_value=None, bint ignore_na=False,
426426
object mask=None, bint return_inverse=False):
@@ -465,7 +465,7 @@ cdef class {{name}}HashTable(HashTable):
465465
Py_ssize_t i, idx, count = count_prior, n = len(values)
466466
int64_t[:] labels
467467
int ret = 0
468-
{{dtype}}_t val, na_value2
468+
{{c_type}} val, na_value2
469469
khiter_t k
470470
{{name}}VectorData *ud
471471
bint use_na_value, use_mask
@@ -538,7 +538,7 @@ cdef class {{name}}HashTable(HashTable):
538538
return uniques.to_array(), np.asarray(labels)
539539
return uniques.to_array()
540540

541-
def unique(self, const {{dtype}}_t[:] values, bint return_inverse=False):
541+
def unique(self, const {{c_type}}[:] values, bint return_inverse=False):
542542
"""
543543
Calculate unique values and labels (no sorting!)
544544

@@ -561,7 +561,7 @@ cdef class {{name}}HashTable(HashTable):
561561
return self._unique(values, uniques, ignore_na=False,
562562
return_inverse=return_inverse)
563563

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,
565565
object na_value=None, object mask=None):
566566
"""
567567
Calculate unique values and labels (no sorting!)
@@ -606,13 +606,13 @@ cdef class {{name}}HashTable(HashTable):
606606
return labels
607607

608608
@cython.boundscheck(False)
609-
def get_labels_groupby(self, const {{dtype}}_t[:] values):
609+
def get_labels_groupby(self, const {{c_type}}[:] values):
610610
cdef:
611611
Py_ssize_t i, n = len(values)
612612
intp_t[:] labels
613613
Py_ssize_t idx, count = 0
614614
int ret = 0
615-
{{dtype}}_t val
615+
{{c_type}} val
616616
khiter_t k
617617
{{name}}Vector uniques = {{name}}Vector()
618618
{{name}}VectorData *ud

pandas/_libs/hashtable_func_helper.pxi.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dtypes = [('float64', 'float64', 'float64_t'),
3030
cdef build_count_table_{{dtype}}(ndarray[{{dtype}}] values,
3131
kh_{{ttype}}_t *table, bint dropna):
3232
{{else}}
33-
cdef build_count_table_{{dtype}}({{dtype}}_t[:] values,
33+
cdef build_count_table_{{dtype}}({{c_type}}[:] values,
3434
kh_{{ttype}}_t *table, bint dropna):
3535
{{endif}}
3636
cdef:
@@ -138,7 +138,7 @@ def duplicated_{{dtype}}(const {{c_type}}[:] values, object keep='first'):
138138
cdef:
139139
int ret = 0
140140
{{if dtype != 'object'}}
141-
{{dtype}}_t value
141+
{{c_type}} value
142142
{{endif}}
143143
Py_ssize_t i, n = len(values)
144144
khiter_t k

0 commit comments

Comments
 (0)