blosc2.NDArray.resize#

NDArray.resize(newshape: tuple | list) None#

Change the shape of the array by growing or shrinking one or more dimensions.

Parameters:

newshape (tuple or list) – The new shape of the array. It should have the same number of dimensions as self, the current shape.

Returns:

out

Return type:

None

Notes

The array values in the newly added positions are not initialized. The user is responsible for initializing them.

Examples

>>> import blosc2
>>> import numpy as np
>>> import math
>>> dtype = np.dtype(np.float32)
>>> shape = [23, 11]
>>> a = np.linspace(1, 3, num=math.prod(shape)).reshape(shape)
>>> # Create an array
>>> b = blosc2.asarray(a)
>>> newshape = [50, 10]
>>> # Extend first dimension, shrink second dimension
>>> b.resize(newshape)
>>> b.shape
(50, 10)