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

Bug for points sharing the same coordinate #9

Open
kletzi opened this issue Feb 8, 2024 · 0 comments
Open

Bug for points sharing the same coordinate #9

kletzi opened this issue Feb 8, 2024 · 0 comments

Comments

@kletzi
Copy link

kletzi commented Feb 8, 2024

Hi, there seems to be a bug when points share the same coordinates. See the following example:

tree = KDTree([(7, 3), (5, 3), (2, 3)], 2)
print(tree.get_knn((5, 3), 2, False))

I would expect to get [(5, 3), (7, 3)] as the result, but I get [(5, 3), (2, 3)].

The solution seems to be that in line 70 instead of dx * dx < -heap[0][0] it should be <= for going into the second branch (or to make sure it works well with floats: dx * dx < -heap[0][0] + 1e-6).

With this change I get the expected result.

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

1 participant