bounding.py 文件源码

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

项目:dynesty 作者: joshspeagle 项目源码 文件源码
def within(self, x, ctrs, kdtree=None):
        """Checks which cubes `x` falls within. Uses a K-D Tree to
        accelerate the search if provided."""

        if kdtree is None:
            # If no KDTree is provided, execute a brute-force search
            # over all cubes.
            nctrs = len(ctrs)
            within = np.array([max(abs(ctrs[i] - x)) <= self.hside
                               for i in range(nctrs)], dtype='bool')
            idxs = np.arange(nctrs)[within]
        else:
            # If a KDTree is provided, find all points within r (`hside`).
            idxs = kdtree.query_ball_point(x, self.hside, p=np.inf, eps=0)

        return idxs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号