Skip to content

A little question #2

@yyb1995

Description

@yyb1995

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions