statistical_learning icon indicating copy to clipboard operation
statistical_learning copied to clipboard

A little question

Open yyb1995 opened this issue 5 years ago • 0 comments

I found a small problem while running KD-tree. If the target point has the same distance to more than one node, e.g., target = array([7.5, 3.5]), it will throw the following error

TypeError: '<' not supported between instances of 'Node' and 'Node'

I think it's because heapq.nlargest() need to compare items in heap. So it can't compare two items with the same distance, e.g., (1.5, Node1) and (1.5, Node2). A quick solution is adding an index to each item, like (1.5, 1, Node1) and (1.5, 2, Node2).

yyb1995 avatar Aug 21 '19 08:08 yyb1995