Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_n_nearest_neighbors() returns less nodes than n for query close to root #4

Closed
tenomoto opened this issue Jun 27, 2018 · 1 comment

Comments

@tenomoto
Copy link

In the extreme case of query being the root vantage point, furthest_d becomes zero and no further nodes are searched because d is less than node.left_min. The left subtree should be searched if d < middle where middle = (self.left_max + self.right_min).

References:

RickardSjogren added a commit that referenced this issue Jul 2, 2018
valentin-pinkau added a commit to valentin-pinkau/vptree that referenced this issue Jul 24, 2018
RickardSjogren added a commit that referenced this issue Aug 6, 2018
@bruggsy
Copy link

bruggsy commented Dec 27, 2018

Hi, I'm still seeing this issue when trying to use this library. I'm on version 1.1.1, is this the version that has these fixes or am I mistaken? Including some test code below.

Thanks! Happy holidays.

import numpy as np
import vptree

def euclidean(p1, p2):
  return np.sqrt(np.sum(np.power(p2 - p1, 2)))

foo = np.array([[2.5,3.3,2.1],[1.0,1.0,1.0],[4.2,4.0,5.0]])

tree = vptree.VPTree(foo,euclidean)

tree.get_n_nearest_neighbors(foo[1],3)

# [(0.0, array([ 1.,  1.,  1.])), (2.9580398915498081, array([ 2.5,  3.3,  2.1]))]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants