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))
评论列表
文章目录