Skip to content

Commit 4ac7a5a

Browse files
committed
introducing IntpHashMap
1 parent 6599834 commit 4ac7a5a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pandas/_libs/hashtable.pyx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ cdef Py_ssize_t _INIT_VEC_CAP = 128
6565
include "hashtable_class_helper.pxi"
6666
include "hashtable_func_helper.pxi"
6767

68+
69+
# map derived hash-map types onto basic hash-map types:
70+
if np.dtype(np.intp) == np.dtype(np.int64):
71+
IntpHashTable = Int64HashTable
72+
value_count_intp = value_count_int64
73+
duplicated_intp = duplicated_int64
74+
ismember_intp = ismember_int64
75+
mode_intp = mode_int64
76+
elif np.dtype(np.intp) == np.dtype(np.int32):
77+
IntpHashTable = Int32HashTable
78+
value_count_intp = value_count_int32
79+
duplicated_intp = duplicated_int32
80+
ismember_intp = ismember_int32
81+
mode_intp = mode_int32
82+
else:
83+
raise ValueError(np.dtype(np.intp))
84+
85+
6886
cdef class Factorizer:
6987
cdef readonly:
7088
Py_ssize_t count

pandas/tests/libs/test_hashtable.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_allocated_khash_memory():
4444
(ht.UInt16HashTable, np.uint16),
4545
(ht.Int8HashTable, np.int8),
4646
(ht.UInt8HashTable, np.uint8),
47+
(ht.IntpHashTable, np.intp),
4748
],
4849
)
4950
class TestHashTable:
@@ -389,6 +390,7 @@ def get_ht_function(fun_name, type_suffix):
389390
(np.uint16, "uint16"),
390391
(np.int8, "int8"),
391392
(np.uint8, "uint8"),
393+
(np.intp, "intp"),
392394
],
393395
)
394396
class TestHelpFunctions:

0 commit comments

Comments
 (0)