class_docstr: kd-tree for quick nearest-neighbor lookup
  
  This class provides an index into a set of k-dimensional points which
  can be used to rapidly look up the nearest neighbors of any point.
  
  Parameters
  ----------
  data : (N,K) array_like
      The data points to be indexed. This array is not copied, and
      so modifying this data will result in bogus results.
  leafsize : int, optional
      The number of points at which the algorithm switches over to
      brute-force.  Has to be positive.
  
  Raises
  ------
  RuntimeError
      The maximum recursion limit can be exceeded for large data
      sets.  If this happens, either increase the value for the `leafsize`
      parameter or increase the recursion limit by::
  
          >>> import sys
          >>> sys.setrecursionlimit(10000)
  
  See Also
  --------
  cKDTree : Implementation of `KDTree` in Cython
  
  Notes
  -----
  The algorithm used is described in Maneewongvatana and Mount 1999.
  The general idea is that the kd-tree is a binary tree, each of whose
  nodes represents an axis-aligned hyperrectangle. Each node specifies
  an axis and splits the set of points based on whether their coordinate
  along that axis is greater than or less than a particular value.
  
  During construction, the axis and splitting point are chosen by the
  "sliding midpoint" rule, which ensures that the cells do not all
  become long and thin.
  
  The tree can be queried for the r closest neighbors of any given point
  (optionally returning only those within some maximum distance of the
  point). It can also be queried, with a substantial gain in efficiency,
  for the r approximate closest neighbors.
  
  For large dimensions (20 is already large) do not expect this to run
  significantly faster than brute force. High-dimensional nearest-neighbor
  queries are a substantial open problem in computer science.
  
  The tree also supports all-neighbors queries, both with arrays of points
  and with other kd-trees. These do use a reasonably efficient algorithm,
  but the kd-tree is not necessarily the best data structure for this
  sort of calculation.
docstr: Find all points within distance r of point(s) x.
  
  Parameters
  ----------
  x : array_like, shape tuple + (self.m,)
      The point or points to search for neighbors of.
  r : positive float
      The radius of points to return.
  p : float, optional
      Which Minkowski p-norm to use.  Should be in the range [1, inf].
  eps : nonnegative 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)``.
  
  Returns
  -------
  results : list or array of lists
      If `x` is a single point, returns a list of the indices of the
      neighbors of `x`. If `x` is an array of points, returns an object
      array of shape tuple containing lists of neighbors.
  
  Notes
  -----
  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.
  
  Examples
  --------
  >>> from scipy import spatial
  >>> x, y = np.mgrid[0:5, 0:5]
  >>> points = np.c_[x.ravel(), y.ravel()]
  >>> tree = spatial.KDTree(points)
  >>> tree.query_ball_point([2, 0], 1)
  [5, 10, 11, 15]
  
  Query multiple points and plot the results:
  
  >>> import matplotlib.pyplot as plt
  >>> points = np.asarray(points)
  >>> plt.plot(points[:,0], points[:,1], '.')
  >>> for results in tree.query_ball_point(([2, 0], [3, 3]), 1):
  ...     nearby_points = points[results]
  ...     plt.plot(nearby_points[:,0], nearby_points[:,1], 'o')
  >>> plt.margins(0.1, 0.1)
  >>> plt.show()
docstr_tok: ["Find","all","points","within","distance","r","of","point","(","s",")","x.","Parameters","--","--","--","--","--","x",":","array_like",",","shape","tuple","+","(","self.m",",",")","The","point","or","points","to","search","for","neighbors","of",".","r",":","positive","float","The","radius","of","points","to","return",".","p",":","float",",","optional","Which","Minkowski","p-norm","to","use",".","Should","be","in","the","range","[","1",",","inf","]",".","eps",":","nonnegative","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",")","``",".","Returns","--","--","--","-","results",":","list","or","array","of","lists","If","`","x","`","is","a","single","point",",","returns","a","list","of","the","indices","of","the","neighbors","of","`","x","`",".","If","`","x","`","is","an","array","of","points",",","returns","an","object","array","of","shape","tuple","containing","lists","of","neighbors",".","Notes","--","--","-","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",".","Examples","--","--","--","--",">",">",">","from","scipy","import","spatial",">",">",">","x",",","y","=","np.mgrid","[","0:5",",","0:5","]",">",">",">","points","=","np.c_","[","x.ravel","(",")",",","y.ravel","(",")","]",">",">",">","tree","=","spatial.KDTree","(","points",")",">",">",">","tree.query_ball_point","(","[","2",",","0","]",",","1",")","[","5",",","10",",","11",",","15","]","Query","multiple","points","and","plot","the","results",":",">",">",">","import","matplotlib.pyplot","as","plt",">",">",">","points","=","np.asarray","(","points",")",">",">",">","plt.plot","(","points","[",":",",0","]",",","points","[",":",",1","]",",","'",".","'",")",">",">",">","for","results","in","tree.query_ball_point","(","(","[","2",",","0","]",",","[","3",",","3","]",")",",","1",")",":","...","nearby_points","=","points","[","results","]","...","plt.plot","(","nearby_points","[",":",",0","]",",","nearby_points","[",":",",1","]",",","'","o","'",")",">",">",">","plt.margins","(","0.1",",","0.1",")",">",">",">","plt.show","(",")"]
code: def query_ball_point(self, x, r, p=2.0, eps=0):
      """Find all points within distance r of point(s) x.
  
      Parameters
      ----------
      x : array_like, shape tuple + (self.m,)
          The point or points to search for neighbors of.
      r : positive float
          The radius of points to return.
      p : float, optional
          Which Minkowski p-norm to use.  Should be in the range [1, inf].
      eps : nonnegative 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)``.
  
      Returns
      -------
      results : list or array of lists
          If `x` is a single point, returns a list of the indices of the
          neighbors of `x`. If `x` is an array of points, returns an object
          array of shape tuple containing lists of neighbors.
  
      Notes
      -----
      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.
  
      Examples
      --------
      >>> from scipy import spatial
      >>> x, y = np.mgrid[0:5, 0:5]
      >>> points = np.c_[x.ravel(), y.ravel()]
      >>> tree = spatial.KDTree(points)
      >>> tree.query_ball_point([2, 0], 1)
      [5, 10, 11, 15]
  
      Query multiple points and plot the results:
  
      >>> import matplotlib.pyplot as plt
      >>> points = np.asarray(points)
      >>> plt.plot(points[:,0], points[:,1], '.')
      >>> for results in tree.query_ball_point(([2, 0], [3, 3]), 1):
      ...     nearby_points = points[results]
      ...     plt.plot(nearby_points[:,0], nearby_points[:,1], 'o')
      >>> plt.margins(0.1, 0.1)
      >>> plt.show()
  
      """
      x = np.asarray(x)
      if x.shape[-1] != self.m:
          raise ValueError(
              "Searching for a %d-dimensional point in a "
              "%d-dimensional KDTree" % (x.shape[-1], self.m)
          )
      if len(x.shape) == 1:
          return self.__query_ball_point(x, r, p, eps)
      else:
          retshape = x.shape[:-1]
          result = np.empty(retshape, dtype=object)
          for c in np.ndindex(retshape):
              result[c] = self.__query_ball_point(x[c], r, p=p, eps=eps)
          return result
  
imports: from __future__ import division, print_function, absolute_import
  import sys
  import numpy
  from heapq import heappush, heappop
  import scipy.sparse
label_desc: Use image node_id 6 for calling the KDTree obj's underlying member method code with example usage: obj.query_ball_point(x, r, p, eps) and returns: self, result