blosc2.reshape#
- blosc2.reshape(src: NDArray | NDField | LazyArray | C2Array, shape: tuple | list, c_order: bool = True, **kwargs: Any) NDArray #
Returns an array containing the same data with a new shape.
This only works when src.shape is 1-dimensional. Multidim case for src is interesting, but not supported yet.
- Parameters:
src¶ (NDArray or NDField or LazyArray or C2Array) – The input array.
shape¶ (tuple or list) – The new shape of the array. It should have the same number of elements as the current shape.
c_order¶ (bool) – Whether to reshape the array in C order (row-major) or insertion order. Insertion order means that values will be stored in the array following the order of chunks in the source array. Default is C order.
kwargs¶ (dict, optional) – Additional keyword arguments supported by the
empty()
constructor.
- Returns:
out – A new array with the requested shape.
- Return type:
Examples
>>> import blosc2 >>> import numpy as np >>> shape = [23 * 11] >>> a = np.arange(np.prod(shape)) >>> # Create an array >>> b = blosc2.asarray(a) >>> # Reshape the array >>> c = blosc2.reshape(b, (11, 23)) >>> print(c.shape) (11, 23)