import kdtree
points = [(x,y) for x in xrange(10) for y in xrange(10)]
tree = kdtree.create(points)
nn = tree.search_nn_dist((5,5), 2.5)
assert nn == [kdtree.KDNode((5, 5))]
d = kdtree.KDNode((5,5)).dist((6,6))
assert d == 2.0
That means, even though the distance between (5,5) and (6,6) is less than 2.5, tree.search_nn_dist((5,5), 2.5) can't get (6,6) in its result.
import kdtree points = [(x,y) for x in xrange(10) for y in xrange(10)] tree = kdtree.create(points) nn = tree.search_nn_dist((5,5), 2.5) assert nn == [kdtree.KDNode((5, 5))] d = kdtree.KDNode((5,5)).dist((6,6)) assert d == 2.0
That means, even though the distance between (5,5) and (6,6) is less than 2.5, tree.search_nn_dist((5,5), 2.5) can't get (6,6) in its result.