kdtree.py 文件源码

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

项目:pytorch-nec 作者: mjacar 项目源码 文件源码
def children(self):
        """
        Returns an iterator for the non-empty children of the Node
        The children are returned as (Node, pos) tuples where pos is 0 for the
        left subnode and 1 for the right.
        >>> len(list(create(dimensions=2).children))
        0
        >>> len(list(create([ Variable(torch.Tensor([[1, 2]])) ]).children))
        0
        >>> len(list(create([ Variable(torch.Tensor([[2, 2]])), Variable(torch.Tensor([[2, 1]])), Variable(torch.Tensor([[2, 3]])) ]).children))
        2
        """

        if self.left and self.left.data is not None:
            yield self.left, 0
        if self.right and self.right.data is not None:
            yield self.right, 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号