@@ -539,12 +539,12 @@ cdef class {{name}}HashTable(HashTable):
539
539
-------
540
540
uniques : ndarray[{{dtype}}]
541
541
Unique values of input, not sorted
542
- labels : ndarray[int64 ] (if return_inverse=True)
542
+ labels : ndarray[intp_t ] (if return_inverse=True)
543
543
The labels from values to uniques
544
544
"""
545
545
cdef:
546
546
Py_ssize_t i, idx, count = count_prior, n = len(values)
547
- int64_t [:] labels
547
+ intp_t [:] labels
548
548
int ret = 0
549
549
{{c_type}} val, na_value2
550
550
khiter_t k
@@ -553,7 +553,7 @@ cdef class {{name}}HashTable(HashTable):
553
553
uint8_t[:] mask_values
554
554
555
555
if return_inverse:
556
- labels = np.empty(n, dtype=np.int64 )
556
+ labels = np.empty(n, dtype=np.intp )
557
557
ud = uniques.data
558
558
use_na_value = na_value is not None
559
559
use_mask = mask is not None
@@ -614,7 +614,7 @@ cdef class {{name}}HashTable(HashTable):
614
614
labels[i] = idx
615
615
616
616
if return_inverse:
617
- return uniques.to_array(), np.asarray( labels)
617
+ return uniques.to_array(), labels.base # .base -> underlying ndarray
618
618
return uniques.to_array()
619
619
620
620
def unique(self, const {{dtype}}_t[:] values, bint return_inverse=False):
@@ -633,7 +633,7 @@ cdef class {{name}}HashTable(HashTable):
633
633
-------
634
634
uniques : ndarray[{{dtype}}]
635
635
Unique values of input, not sorted
636
- labels : ndarray[int64 ] (if return_inverse)
636
+ labels : ndarray[intp_t ] (if return_inverse)
637
637
The labels from values to uniques
638
638
"""
639
639
uniques = {{name}}Vector()
@@ -668,7 +668,7 @@ cdef class {{name}}HashTable(HashTable):
668
668
-------
669
669
uniques : ndarray[{{dtype}}]
670
670
Unique values of input, not sorted
671
- labels : ndarray[int64 ]
671
+ labels : ndarray[intp_t ]
672
672
The labels from values to uniques
673
673
"""
674
674
uniques_vector = {{name}}Vector()
@@ -918,12 +918,12 @@ cdef class StringHashTable(HashTable):
918
918
-------
919
919
uniques : ndarray[object]
920
920
Unique values of input, not sorted
921
- labels : ndarray[int64 ] (if return_inverse=True)
921
+ labels : ndarray[intp_t ] (if return_inverse=True)
922
922
The labels from values to uniques
923
923
"""
924
924
cdef:
925
925
Py_ssize_t i, idx, count = count_prior, n = len(values)
926
- int64_t [:] labels
926
+ intp_t [:] labels
927
927
int64_t[:] uindexer
928
928
int ret = 0
929
929
object val
@@ -933,7 +933,7 @@ cdef class StringHashTable(HashTable):
933
933
bint use_na_value
934
934
935
935
if return_inverse:
936
- labels = np.zeros(n, dtype=np.int64 )
936
+ labels = np.zeros(n, dtype=np.intp )
937
937
uindexer = np.empty(n, dtype=np.int64)
938
938
use_na_value = na_value is not None
939
939
@@ -972,13 +972,13 @@ cdef class StringHashTable(HashTable):
972
972
uindexer[count] = i
973
973
if return_inverse:
974
974
self.table.vals[k] = count
975
- labels[i] = <int64_t> count
975
+ labels[i] = count
976
976
count += 1
977
977
elif return_inverse:
978
978
# k falls into a previous bucket
979
979
# only relevant in case we need to construct the inverse
980
980
idx = self.table.vals[k]
981
- labels[i] = <int64_t> idx
981
+ labels[i] = idx
982
982
983
983
free(vecs)
984
984
@@ -987,7 +987,7 @@ cdef class StringHashTable(HashTable):
987
987
uniques.append(values[uindexer[i]])
988
988
989
989
if return_inverse:
990
- return uniques.to_array(), np.asarray( labels)
990
+ return uniques.to_array(), labels.base # .base -> underlying ndarray
991
991
return uniques.to_array()
992
992
993
993
def unique(self, ndarray[object] values, bint return_inverse=False):
@@ -1193,19 +1193,19 @@ cdef class PyObjectHashTable(HashTable):
1193
1193
-------
1194
1194
uniques : ndarray[object]
1195
1195
Unique values of input, not sorted
1196
- labels : ndarray[int64 ] (if return_inverse=True)
1196
+ labels : ndarray[intp_t ] (if return_inverse=True)
1197
1197
The labels from values to uniques
1198
1198
"""
1199
1199
cdef:
1200
1200
Py_ssize_t i, idx, count = count_prior, n = len(values)
1201
- int64_t [:] labels
1201
+ intp_t [:] labels
1202
1202
int ret = 0
1203
1203
object val
1204
1204
khiter_t k
1205
1205
bint use_na_value
1206
1206
1207
1207
if return_inverse:
1208
- labels = np.empty(n, dtype=np.int64 )
1208
+ labels = np.empty(n, dtype=np.intp )
1209
1209
use_na_value = na_value is not None
1210
1210
1211
1211
for i in range(n):
@@ -1240,7 +1240,7 @@ cdef class PyObjectHashTable(HashTable):
1240
1240
labels[i] = idx
1241
1241
1242
1242
if return_inverse:
1243
- return uniques.to_array(), np.asarray( labels)
1243
+ return uniques.to_array(), labels.base # .base -> underlying ndarray
1244
1244
return uniques.to_array()
1245
1245
1246
1246
def unique(self, ndarray[object] values, bint return_inverse=False):
@@ -1259,7 +1259,7 @@ cdef class PyObjectHashTable(HashTable):
1259
1259
-------
1260
1260
uniques : ndarray[object]
1261
1261
Unique values of input, not sorted
1262
- labels : ndarray[int64 ] (if return_inverse)
1262
+ labels : ndarray[intp_t ] (if return_inverse)
1263
1263
The labels from values to uniques
1264
1264
"""
1265
1265
uniques = ObjectVector()
@@ -1292,7 +1292,7 @@ cdef class PyObjectHashTable(HashTable):
1292
1292
-------
1293
1293
uniques : ndarray[object]
1294
1294
Unique values of input, not sorted
1295
- labels : ndarray[int64 ]
1295
+ labels : ndarray[intp_t ]
1296
1296
The labels from values to uniques
1297
1297
"""
1298
1298
uniques_vector = ObjectVector()
0 commit comments