Skip to content

Commit

Permalink
Clip max neighbors if n < k
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcaixeta committed Apr 25, 2021
1 parent 3917271 commit d64aede
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/data_handling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function get_neighbors(origin::AbstractMatrix, target::AbstractMatrix,
@assert nhood in [:knn,:radius] "invalid neighborhood type"
tree = KDTree(origin)
if nhood==:knn
idxs, dists = knn(tree, target, neigh_val, true)
nneigh = minimum([neigh_val, size(origin,2)])
idxs, dists = knn(tree, target, nneigh, true)
idxs, dists
elseif nhood==:radius
idxs = inrange(tree, target, neigh_val)
Expand Down

0 comments on commit d64aede

Please # to comment.