pykdtree.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:yt 作者: yt-project 项目源码 文件源码
def query_ball_point(self, x, r, p=2., eps=0):
        """Find all points within r of 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 1<=p<=infinity
            Which Minkowski p-norm to use
        eps : nonnegative float
            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.


        Note: 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.
        """
        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=np.object)
            for c in np.ndindex(retshape):
                result[c] = self.__query_ball_point(x[c], r, p=p, eps=eps)
            return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号