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):
dist += d*d
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 len(self.nodes) == 0:
return (None, 0)
best = self.nodes[0]
bestdist = self.dist(node, best)
bestdist = dist(node, best)
for n in self.nodes:
d = self.dist(n, node)
d = dist(n, node)
if d < bestdist:
best = n
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