stefankoegl / kdtree

A Python implementation of a kd-tree
ISC License
365 stars 118 forks source link

Bug fix for search_nn_dist and updating testcase #37

Closed grapemix closed 6 years ago

grapemix commented 6 years ago

To respond #36

grapemix commented 6 years ago

The search_nn_dist() return unexpected result to me and the test case for search_nn_dist() also miss some points. For example, in the test case:

points = [(x,y) for x in range(10) for y in range(10)] tree = kdtree.create(points) nn = tree.search_nn_dist((5,5), 2.5)

self.assertEqual(len(nn), 4) self.assertTrue( (6,6) in nn) self.assertTrue( (5,5) in nn) self.assertTrue( (5,6) in nn) self.assertTrue( (6,5) in nn)

The point(4,4) is missing. The Euclidean distance between (5,5) and (4,4) is 1.414214 and hence should be included if the radius param is 2.5.

Thanks.

stefankoegl commented 6 years ago

Merged - thanks!