Skip to content

Commit

Permalink
🎨 Rewrite nested if to elsif in VPTree
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshoku committed Apr 12, 2020
1 parent a0122d6 commit 51080d8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/rumale/nearest_neighbors/vp_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ def search(q, node, k, tau = Float::INFINITY)
else
node
end
elsif dist + tau >= node.threshold
node.right.n_samples < k ? node : search(q, node.right, k, tau)
elsif dist - tau <= node.threshold
node.left.n_samples < k ? node : search(q, node.left, k, tau)
else
if dist + tau >= node.threshold
node.right.n_samples < k ? node : search(q, node.right, k, tau)
elsif dist - tau <= node.threshold
node.left.n_samples < k ? node : search(q, node.left, k, tau)
else
node
end
node
end
# :nocov:
end
Expand Down

0 comments on commit 51080d8

Please sign in to comment.