Skip to content

Commit 9e9dda5

Browse files
committed
make unique_label_indices use intp
1 parent ca19724 commit 9e9dda5

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

pandas/_libs/hashtable.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ include "hashtable_func_helper.pxi"
7070
if np.dtype(np.intp) == np.dtype(np.int64):
7171
IntpHashTable = Int64HashTable
7272
unique_label_indices = _unique_label_indices_int64
73-
unique_label_indices_intp = _unique_label_indices_int64
7473
elif np.dtype(np.intp) == np.dtype(np.int32):
7574
IntpHashTable = Int32HashTable
76-
unique_label_indices = _unique_label_indices_int64
77-
unique_label_indices_intp = _unique_label_indices_int32
75+
unique_label_indices = _unique_label_indices_int32
7876
else:
7977
raise ValueError(np.dtype(np.intp))
8078

pandas/core/sorting.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ def decons_obs_group_ids(
261261
out = decons_group_index(obs_ids, shape)
262262
return out if xnull or not lift.any() else [x - y for x, y in zip(out, lift)]
263263

264-
# TODO: unique_label_indices only used here, should take ndarray[np.intp]
265-
indexer = unique_label_indices(ensure_int64(comp_ids))
264+
indexer = unique_label_indices(comp_ids)
266265
return [lab[indexer].astype(np.intp, subok=False, copy=True) for lab in labels]
267266

268267

pandas/tests/test_algos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ def test_quantile():
17411741

17421742
def test_unique_label_indices():
17431743

1744-
a = np.random.randint(1, 1 << 10, 1 << 15).astype("int64")
1744+
a = np.random.randint(1, 1 << 10, 1 << 15).astype(np.intp)
17451745

17461746
left = ht.unique_label_indices(a)
17471747
right = np.unique(a, return_index=True)[1]

0 commit comments

Comments
 (0)