def _nn(self, side, v, k=1, radius=np.inf, eps=0.0, p=2):
        """Compute the k nearest neighbors of v in the observed data,
        :arg side  if equal to DATA_X, search among input data.
                     if equal to DATA_Y, search among output data.
        @return  distance and indexes of found nearest neighbors.
        """
        if self.size > 0:
            dists, idxes = Dataset._nn(self, side, v, k, radius, eps, p)
        else:
            return self.buffer._nn(side, v, k, radius, eps, p)
        if self.buffer.size > 0:
            buffer_dists, buffer_idxes = self.buffer._nn(side, v, k, radius, eps, p)
            buffer_idxes = [i + self.size for i in buffer_idxes]
            ziped = zip(dists, idxes)
            buffer_ziped = zip(buffer_dists, buffer_idxes)
            sorted_dists_idxes = sorted(ziped + buffer_ziped, key=lambda di:di[0])
            knns = sorted_dists_idxes[:k]
            return [knn[0] for knn in knns], [knn[1] for knn in knns] 
        else:
            return dists, idxes
def _nn ( self , side , v , k = 1 , radius = np . inf , eps = 0.0 , p = 2 ) : if self . size > 0 : dists , idxes = Dataset . _nn ( self , side , v , k , radius , eps , p ) else : return self . buffer . _nn ( side , v , k , radius , eps , p ) if self . buffer . size > 0 : buffer_dists , buffer_idxes = self . buffer . _nn ( side , v , k , radius , eps , p ) buffer_idxes = [ i + self . size for i in buffer_idxes ] ziped = zip ( dists , idxes ) buffer_ziped = zip ( buffer_dists , buffer_idxes ) sorted_dists_idxes = sorted ( ziped + buffer_ziped , key = lambda di : di [ 0 ] ) knns = sorted_dists_idxes [ : k ] return [ knn [ 0 ] for knn in knns ] , [ knn [ 1 ] for knn in knns ] else : return dists , idxes
Compute the k nearest neighbors of v in the observed data,
        :arg side  if equal to DATA_X, search among input data.
                     if equal to DATA_Y, search among output data.
        @return  distance and indexes of found nearest neighbors.