(self, *shape, **kwargs)
return GPUArray(
            shape=shape,
            dtype=self.dtype,
            allocator=self.allocator,
            base=self,
            gpudata=int(self.gpudata),
            order=order,
        )
Gives a new shape to an array without changing its data.
Gives a new shape to an array without changing its data.
Gives a new shape to an array without changing its data .
def reshape(self, *shape, **kwargs):
        """Gives a new shape to an array without changing its data."""

        # Python 2.x compatibility: use kwargs instead of named 'order' keyword
        order = kwargs.pop("order", "C")

        # TODO: add more error-checking, perhaps
        if not self.flags.forc:
            raise RuntimeError(
                "only contiguous arrays may " "be used as arguments to this operation"
            )

        if isinstance(shape[0], tuple) or isinstance(shape[0], list):
            shape = tuple(shape[0])

        same_contiguity = (order == "C" and self.flags.c_contiguous) or (
            order == "F" and self.flags.f_contiguous
        )

        if shape == self.shape and same_contiguity:
            return self

        if -1 in shape:
            shape = list(shape)
            idx = shape.index(-1)
            size = -reduce(lambda x, y: x * y, shape, 1)
            shape[idx] = self.size // size
            if -1 in shape[idx:]:
                raise ValueError("can only specify one unknown dimension")
            shape = tuple(shape)

        size = reduce(lambda x, y: x * y, shape, 1)
        if size != self.size:
            raise ValueError("total size of new array must be unchanged")

        return GPUArray(
            shape=shape,
            dtype=self.dtype,
            allocator=self.allocator,
            base=self,
            gpudata=int(self.gpudata),
            order=order,
        )
def reshape ( self , * shape , * * kwargs ) : # Python 2.x compatibility: use kwargs instead of named 'order' keyword order = kwargs . pop ( "order" , "C" ) # TODO: add more error-checking, perhaps if not self . flags . forc : raise RuntimeError ( "only contiguous arrays may " "be used as arguments to this operation" ) if isinstance ( shape [ 0 ] , tuple ) or isinstance ( shape [ 0 ] , list ) : shape = tuple ( shape [ 0 ] ) same_contiguity = ( order == "C" and self . flags . c_contiguous ) or ( order == "F" and self . flags . f_contiguous ) if shape == self . shape and same_contiguity : return self if - 1 in shape : shape = list ( shape ) idx = shape . index ( - 1 ) size = - reduce ( lambda x , y : x * y , shape , 1 ) shape [ idx ] = self . size // size if - 1 in shape [ idx : ] : raise ValueError ( "can only specify one unknown dimension" ) shape = tuple ( shape ) size = reduce ( lambda x , y : x * y , shape , 1 ) if size != self . size : raise ValueError ( "total size of new array must be unchanged" ) return GPUArray ( shape = shape , dtype = self . dtype , allocator = self . allocator , base = self , gpudata = int ( self . gpudata ) , order = order , )