Computing and benchmarking a neighbour list search

I am trying to compare a neighbour list search to other implementations, and scipy has one. I am benchmarking it but it seem to be so slow that I don’t really trust what I’m doing. I am just doing this:

Input file:

import numpy as np
from scipy.spatial import KDTree

def pp(points) : 
    kd_tree = KDTree(points) 
    pairs = kd_tree.query_pairs(r=0.05) 
    return pairs 

points = np.random.random((10000,3))

#%timeit pp(points)

then I run:

% ipython3 -i

In [1]: %timeit pp(points)                                                                            
2.78 s ± 134 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

It that correct?

Any tips on how to get the neighbour list faster (by tunning parameters of this package or using something else?)

1 Like