blosc2.NDArray.resize#

NDArray.resize(newshape)#

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 dimensions as self.

Notes

The array values corresponding to the added positions are not initialized. Thus, the user is in charge of initializing them.

Examples

>>> import blosc2
>>> import numpy as np
>>> dtype = np.dtype(np.float32)
>>> shape = [23, 11]
>>> a = np.linspace(1, 3, num=int(np.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)