Skip to content

Commit

Permalink
fix number format for pynndescent.NNDescent
Browse files Browse the repository at this point in the history
  • Loading branch information
katosh committed Feb 13, 2025
1 parent 8217580 commit 0a5a491
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mellon/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
DEFAULT_SIGMA,
)
from .validation import (
validate_array,
validate_time_x,
validate_positive_float,
validate_float_or_int,
Expand Down Expand Up @@ -375,6 +376,7 @@ def compute_distances(x, k, seed=DEFAULT_RANDOM_SEED):
The returned result discards the self-distance (first column). The `seed` parameter controls
the random state used to initialize the NNDescent index.
"""
x = validate_array(x, "x")
x = ensure_2d(x)
n_samples = x.shape[0]

Expand All @@ -387,8 +389,10 @@ def compute_distances(x, k, seed=DEFAULT_RANDOM_SEED):

# The nearest neighbor of a point is itself, so request k+1 neighbors.
index = pynndescent.NNDescent(
x, n_neighbors=k + 1, metric="euclidean", random_state=seed
x, n_neighbors=k + 1,
metric="euclidean",
)

_, distances = index.neighbor_graph
return distances[:, 1:]

Expand Down

0 comments on commit 0a5a491

Please sign in to comment.