Commit 19fd8a55 authored by sumpfralle's avatar sumpfralle

the optional parameter "dist" in "nearest_neighbor" was ignored before

 * based on an anonymous contribution: https://sourceforge.net/tracker/?func=detail&aid=3030183&group_id=237831&atid=1104178


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@657 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 56f6e132
...@@ -172,14 +172,16 @@ class kdtree(object): ...@@ -172,14 +172,16 @@ class kdtree(object):
dist += d*d dist += d*d
return dist return dist
def nearest_neighbor(self, node, dist=dist): def nearest_neighbor(self, node, dist=None):
if dist is None:
dist = self.dist
if self.bucket: if self.bucket:
if len(self.nodes) == 0: if len(self.nodes) == 0:
return (None, 0) return (None, 0)
best = self.nodes[0] best = self.nodes[0]
bestdist = self.dist(node, best) bestdist = dist(node, best)
for n in self.nodes: for n in self.nodes:
d = self.dist(n, node) d = dist(n, node)
if d < bestdist: if d < bestdist:
best = n best = n
bestdist = d bestdist = d
......
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