Skip to content

Commit 512c6aa

Browse files
committed
Fix: Generating 64-bit unsigned seeds
The previous solution failed on Windows with: > ValueError: high is out of bounds for int32
1 parent 6f132bb commit 512c6aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/usearch/index.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,9 @@ def kmeans(
16651665
"""
16661666
metric = _normalize_metric(metric)
16671667
dtype = _normalize_dtype(dtype, ndim=X.shape[1], metric=metric)
1668-
seed = np.random.randint(0, 2**32 - 1) if seed is None else seed
1668+
1669+
# Generating a 64-bit unsigned integer in NumPy may be somewhat tricky.
1670+
seed = np.random.default_rng().integers(0, 2**64, dtype=np.uint64) if seed is None else seed
16691671
assignments, distances, centroids = _kmeans(
16701672
X,
16711673
k,

0 commit comments

Comments
 (0)