Commit 4689a19c authored by Julien Jerphanion's avatar Julien Jerphanion

Use Heap to query multiples neighbours

parent 1dfa85af
This diff is collapsed.
import numpy as np
import pytest
import kdtree
from sklearn.neighbors import KDTree
if __name__ == '__main__':
n = 1000
n_query = 100
d = 10
k = 10
np.random.seed(1)
X = np.random.rand(n, d)
query_points = np.random.rand(n_query, d)
tree = kdtree.KDTree(X, leaf_size=256)
closests = np.zeros((n_query, k), dtype=np.int32)
# There's currently a deadlock here
tree.query(query_points, closests)
\ No newline at end of file
...@@ -14,8 +14,8 @@ def test_against_sklearn(n, d, leaf_size): ...@@ -14,8 +14,8 @@ def test_against_sklearn(n, d, leaf_size):
tree = kdtree.KDTree(X, leaf_size=256) tree = kdtree.KDTree(X, leaf_size=256)
skl_tree = KDTree(X, leaf_size=256) skl_tree = KDTree(X, leaf_size=256)
closests = np.zeros((n), dtype=np.int32) closests = np.zeros((n, 2), dtype=np.int32)
tree.get_closest(query_points, closests) tree.query(query_points, closests)
skl_closests = skl_tree.query(query_points, return_distance=False) skl_closests = skl_tree.query(query_points, return_distance=False)
# The back tracking part of the algorithm is not yet implemented # The back tracking part of the algorithm is not yet implemented
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment