reshape

reshape(x: array, /, shape: Tuple[int, ...], *, copy: bool | None = None) array

Reshapes an array without changing its data.

Parameters:
  • x (array) – input array to reshape.

  • shape (Tuple[int, ...]) – a new shape compatible with the original shape. One shape dimension is allowed to be -1. When a shape dimension is -1, the corresponding output array shape dimension must be inferred from the length of the array and the remaining dimensions.

  • copy (Optional[bool]) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

Returns:

out (array) – an output array having the same data type and elements as x.