def reshape(self, *newShape):
if len(newShape)==1 and not type(newShape[0]) in _numberTypes: newShape = tuple(newShape[0])
if not _all2_(newShape, _isNumber): raise TypeError('the parameters to reshape don\'t look like a valid shape')
if -1 in newShape:
if _prodT(newShape)==0: raise ValueError("-1 as a parameter to reshape is not allowed if one of the other parameters is zero.")
newShape = _modifyT(newShape, operator.indexOf(newShape, -1), self.size//-_prodT(newShape))
if _prodT(newShape) != self.size: raise ValueError('the total number of items cannot be changed in a reshape')
return garray(self._base, newShape, self)
评论列表
文章目录