nodes: 0, module; 1, function_definition; 2, function_name:query; 3, parameters; 4, block; 5, identifier:self; 6, identifier:x; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:k; 14, integer:1; 15, identifier:p; 16, integer:2; 17, identifier:distance_upper_bound; 18, attribute; 19, comment:"""Query the kd-tree for nearest neighbors
  
          Parameters
          ----------
          x : array_like, last dimension self.m
              An array of points to query.
          k : int, optional
              The number of nearest neighbors to return.
          eps : nonnegative float, optional
              Return approximate nearest neighbors; the kth returned value
              is guaranteed to be no further than (1+eps) times the
              distance to the real kth nearest neighbor.
          p : float, 1<=p<=infinity, optional
              Which Minkowski p-norm to use.
              1 is the sum-of-absolute-values "Manhattan" distance
              2 is the usual Euclidean distance
              infinity is the maximum-coordinate-difference distance
          distance_upper_bound : nonnegative float, optional
              Return only neighbors within this distance. This is used to prune
              tree searches, so if you are doing a series of nearest-neighbor
              queries, it may help to supply the distance to the nearest neighbor
              of the most recent point.
  
          Returns
          -------
          d : float or array of floats
              The distances to the nearest neighbors.
              If x has shape tuple+(self.m,), then d has shape tuple if
              k is one, or tuple+(k,) if k is larger than one. Missing
              neighbors (e.g. when k > n or distance_upper_bound is
              given) are indicated with infinite distances.  If k is None,
              then d is an object array of shape tuple, containing lists
              of distances. In either case the hits are sorted by distance
              (nearest first).
          i : tuple(int, int) or array of tuple(int, int)
              The locations of the neighbors in self.data. Locations are
              given by tuples of (traj_i, frame_i)
  
          Examples
          --------
          >>> from msmbuilder.utils import KDTree
          >>> X1 = 0.3 * np.random.RandomState(0).randn(500, 2)
          >>> X2 = 0.3 * np.random.RandomState(1).randn(1000, 2) + 10
          >>> tree = KDTree([X1, X2])
          >>> pts = np.array([[0, 0], [10, 10]])
          >>> tree.query(pts)
          (array([ 0.0034,  0.0102]), array([[  0, 410], [  1, 670]]))
          >>> tree.query(pts[0])
          (0.0034, array([  0, 410]))
          """; 20, assignment; 21, expression_list; 22, identifier:np; 23, identifier:inf; 24, pattern_list; 25, call; 26, identifier:cdists; 27, call; 28, identifier:cdists; 29, identifier:cinds; 30, attribute; 31, argument_list; 32, attribute; 33, argument_list; 34, attribute; 35, identifier:query; 36, identifier:x; 37, identifier:k; 38, identifier:p; 39, identifier:distance_upper_bound; 40, identifier:self; 41, identifier:_split_indices; 42, identifier:cinds; 43, identifier:self; 44, identifier:_kdtree
code: def query(self, x, k=1, p=2, distance_upper_bound=np.inf):
          """Query the kd-tree for nearest neighbors
  
          Parameters
          ----------
          x : array_like, last dimension self.m
              An array of points to query.
          k : int, optional
              The number of nearest neighbors to return.
          eps : nonnegative float, optional
              Return approximate nearest neighbors; the kth returned value
              is guaranteed to be no further than (1+eps) times the
              distance to the real kth nearest neighbor.
          p : float, 1<=p<=infinity, optional
              Which Minkowski p-norm to use.
              1 is the sum-of-absolute-values "Manhattan" distance
              2 is the usual Euclidean distance
              infinity is the maximum-coordinate-difference distance
          distance_upper_bound : nonnegative float, optional
              Return only neighbors within this distance. This is used to prune
              tree searches, so if you are doing a series of nearest-neighbor
              queries, it may help to supply the distance to the nearest neighbor
              of the most recent point.
  
          Returns
          -------
          d : float or array of floats
              The distances to the nearest neighbors.
              If x has shape tuple+(self.m,), then d has shape tuple if
              k is one, or tuple+(k,) if k is larger than one. Missing
              neighbors (e.g. when k > n or distance_upper_bound is
              given) are indicated with infinite distances.  If k is None,
              then d is an object array of shape tuple, containing lists
              of distances. In either case the hits are sorted by distance
              (nearest first).
          i : tuple(int, int) or array of tuple(int, int)
              The locations of the neighbors in self.data. Locations are
              given by tuples of (traj_i, frame_i)
  
          Examples
          --------
          >>> from msmbuilder.utils import KDTree
          >>> X1 = 0.3 * np.random.RandomState(0).randn(500, 2)
          >>> X2 = 0.3 * np.random.RandomState(1).randn(1000, 2) + 10
          >>> tree = KDTree([X1, X2])
          >>> pts = np.array([[0, 0], [10, 10]])
          >>> tree.query(pts)
          (array([ 0.0034,  0.0102]), array([[  0, 410], [  1, 670]]))
          >>> tree.query(pts[0])
          (0.0034, array([  0, 410]))
          """
          cdists, cinds = self._kdtree.query(x, k, p, distance_upper_bound)
          return cdists, self._split_indices(cinds)