Find all points within distance r of point(s) x.
x : array_like, shape tuple + (self.m,)
r : positive float
p : float, optional
eps : nonnegative float, optional
results : list or array of lists
If you have many points whose neighbors you want to find, you may save substantial amounts of time by putting them in a KDTree and using query_ball_tree.
>>> from scipy import spatial >>> x, y = np.mgrid[0:4, 0:4] >>> points = zip(x.ravel(), y.ravel()) >>> tree = spatial.KDTree(points) >>> tree.query_ball_point([2, 0], 1) [4, 8, 9, 12]