SciPy

scipy.spatial.cKDTree.query_ball_tree

cKDTree.query_ball_tree(self, other, r, p, eps)

Find all pairs of points whose distance is at most r

Parameters :

other : KDTree instance

The tree containing points to search against.

r : float

The maximum distance, has to be positive.

p : float, optional

Which Minkowski norm to use. p has to meet the condition 1 <= p <= infinity.

eps : float, optional

Approximate search. Branches of the tree are not explored if their nearest points are further than r/(1+eps), and branches are added in bulk if their furthest points are nearer than r * (1+eps). eps has to be non-negative.

Returns :

results : list of lists

For each element self.data[i] of this tree, results[i] is a list of the indices of its neighbors in other.data.