simpleneighbors icon indicating copy to clipboard operation
simpleneighbors copied to clipboard

The dist function should work with vectors and it does not

Open rupamroy opened this issue 4 years ago • 1 comments

The following code does not work

from simpleneighbors import SimpleNeighbors
sim = SimpleNeighbors(2, 'angular')
sim.feed([('a', (4, 5)),
     ('b', (0, 3)),
     ('c', (-2, 8)),
     ('d', (2, -2))])
sim.build()
print(list(sim.nearest_matching((1, -1), n=1,
    check=lambda x: sim.dist((1, -1), x) < 0.5)))

Even if we provide the full item it does not work

from simpleneighbors import SimpleNeighbors
sim = SimpleNeighbors(2, 'angular')
sim.feed([('a', (4, 5)),
     ('b', (0, 3)),
     ('c', (-2, 8)),
     ('d', (2, -2))])
sim.build()
print(list(sim.nearest_matching((1, -1), n=1,
    check=lambda x: sim.dist(('k', (1, -1)), x) < 0.5)))

rupamroy avatar Jul 13 '20 19:07 rupamroy

Yep, this would be a helpful feature that is currently missing from the library.

aparrish avatar Aug 06 '20 22:08 aparrish