@@ -32,7 +32,7 @@ dtypes = [('complex128', 'complex128', 'khcomplex128_t', True),
32
32
cdef build_count_table_{{dtype}}(ndarray[{{dtype}}] values,
33
33
kh_{{ttype}}_t *table, bint dropna):
34
34
{{else}}
35
- cdef build_count_table_{{dtype}}({{c_type}} [:] values,
35
+ cdef build_count_table_{{dtype}}(const {{dtype}}_t [:] values,
36
36
kh_{{ttype}}_t *table, bint dropna):
37
37
{{endif}}
38
38
cdef:
@@ -47,8 +47,11 @@ cdef build_count_table_{{dtype}}({{c_type}}[:] values,
47
47
kh_resize_{{ttype}}(table, n // 10)
48
48
49
49
for i in range(n):
50
+ {{if complex_group}}
51
+ val = to_{{c_type}}(values[i])
52
+ {{else}}
50
53
val = values[i]
51
-
54
+ {{endif}}
52
55
if not checknull(val) or not dropna:
53
56
k = kh_get_{{ttype}}(table, <PyObject*>val)
54
57
if k != table.n_buckets:
@@ -61,7 +64,11 @@ cdef build_count_table_{{dtype}}({{c_type}}[:] values,
61
64
kh_resize_{{ttype}}(table, n)
62
65
63
66
for i in range(n):
67
+ {{if complex_group}}
68
+ val = to_{{c_type}}(values[i])
69
+ {{else}}
64
70
val = values[i]
71
+ {{endif}}
65
72
66
73
{{if dtype == 'float64' or dtype == 'float32'}}
67
74
if val == val or not dropna:
@@ -84,7 +91,7 @@ cdef build_count_table_{{dtype}}({{c_type}}[:] values,
84
91
{{if dtype == 'object'}}
85
92
cpdef value_count_{{dtype}}(ndarray[{{dtype}}] values, bint dropna):
86
93
{{else}}
87
- cpdef value_count_{{dtype}}({{c_type}} [:] values, bint dropna):
94
+ cpdef value_count_{{dtype}}(const {{dtype}}_t [:] values, bint dropna):
88
95
{{endif}}
89
96
cdef:
90
97
Py_ssize_t i = 0
@@ -338,7 +345,7 @@ def mode_{{dtype}}(ndarray[{{ctype}}] values, bint dropna):
338
345
{{else}}
339
346
340
347
341
- def mode_{{dtype}}({{ctype}} [:] values, bint dropna):
348
+ def mode_{{dtype}}(const {{dtype}}_t [:] values, bint dropna):
342
349
{{endif}}
343
350
cdef:
344
351
int count, max_count = 1
0 commit comments