Skip to content

Commit 29129ae

Browse files
committed
introducing IntpHashMap
1 parent 1a20d13 commit 29129ae

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pandas/_libs/hashtable.pyx

+18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ cdef Py_ssize_t _INIT_VEC_CAP = 128
5555
include "hashtable_class_helper.pxi"
5656
include "hashtable_func_helper.pxi"
5757

58+
59+
# map derived hash-map types onto basic hash-map types:
60+
if np.dtype(np.intp) == np.dtype(np.int64):
61+
IntpHashTable = Int64HashTable
62+
value_count_intp = value_count_int64
63+
duplicated_intp = duplicated_int64
64+
ismember_intp = ismember_int64
65+
mode_intp = mode_int64
66+
elif np.dtype(np.intp) == np.dtype(np.int32):
67+
IntpHashTable = Int32HashTable
68+
value_count_intp = value_count_int32
69+
duplicated_intp = duplicated_int32
70+
ismember_intp = ismember_int32
71+
mode_intp = mode_int32
72+
else:
73+
raise ValueError(np.dtype(np.intp))
74+
75+
5876
cdef class Factorizer:
5977
cdef readonly:
6078
Py_ssize_t count

pandas/tests/libs/test_hashtable.py

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def get_allocated_khash_memory():
4343
(ht.UInt16HashTable, np.uint16),
4444
(ht.Int8HashTable, np.int8),
4545
(ht.UInt8HashTable, np.uint8),
46+
(ht.IntpHashTable, np.intp),
4647
],
4748
)
4849
class TestHashTable:
@@ -297,6 +298,7 @@ def get_ht_function(fun_name, type_suffix):
297298
(np.uint16, "uint16"),
298299
(np.int8, "int8"),
299300
(np.uint8, "uint8"),
301+
(np.intp, "intp"),
300302
],
301303
)
302304
class TestHelpFunctions:

0 commit comments

Comments
 (0)