mparray.py 文件源码

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

项目:mpnum 作者: dseuss 项目源码 文件源码
def reshape(self, newshapes):
        """Reshape physical legs in place.

        Use :py:attr:`~shape` to obtain the shape of the physical legs.

        :param newshapes: A single new shape or a list of new shape.
            Alternatively, you can pass 'prune' to get rid of all legs
            of dimension 1.
        :returns: Reshaped MPA

        .. todo:: Why is this here? What's wrong with the purne function?

        """
        if newshapes == 'prune':
            newshapes = (tuple(s for s in pdim if s > 1) for pdim in self.shape)

        newshapes = tuple(newshapes)
        if not isinstance(newshapes[0], collections.Iterable):
            newshapes = it.repeat(newshapes, times=len(self))

        ltens = [_local_reshape(lten, newshape)
                 for lten, newshape in zip(self._lt, newshapes)]
        return MPArray(LocalTensors(ltens, cform=self.canonical_form))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号