Skip to content

Commit 05a288c

Browse files
committed
make unique_label_indices use intp
1 parent 812a22b commit 05a288c

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
@@ -60,11 +60,9 @@ include "hashtable_func_helper.pxi"
6060
if np.dtype(np.intp) == np.dtype(np.int64):
6161
IntpHashTable = Int64HashTable
6262
unique_label_indices = _unique_label_indices_int64
63-
unique_label_indices_intp = _unique_label_indices_int64
6463
elif np.dtype(np.intp) == np.dtype(np.int32):
6564
IntpHashTable = Int32HashTable
66-
unique_label_indices = _unique_label_indices_int64
67-
unique_label_indices_intp = _unique_label_indices_int32
65+
unique_label_indices = _unique_label_indices_int32
6866
else:
6967
raise ValueError(np.dtype(np.intp))
7068

pandas/core/sorting.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ def decons_obs_group_ids(comp_ids: np.ndarray, obs_ids, shape, labels, xnull: bo
257257
out = decons_group_index(obs_ids, shape)
258258
return out if xnull or not lift.any() else [x - y for x, y in zip(out, lift)]
259259

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

264263

pandas/tests/test_algos.py

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

17271727
def test_unique_label_indices():
17281728

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

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

0 commit comments

Comments
 (0)