blosc2.NDArray.slice#

NDArray.slice(key, **kwargs)#

Get a (multidimensional) slice as a new NDArray.

Parameters:
  • key (int, slice or sequence of slices) – The index for the slices to be updated. Note that the step parameter is not honored yet in slices.

  • kwargs (dict, optional) – Keyword arguments that are supported by the empty() constructor.

Returns:

out – An array with the requested data. The dtype will be the same as self.

Return type:

NDArray

Examples

>>> import blosc2
>>> import numpy as np
>>> shape = [23, 11]
>>> a = np.arange(np.prod(shape)).reshape(shape)
>>> # Create an array
>>> b = blosc2.asarray(a)
>>> slices = (slice(3, 7), slice(1, 11))
>>> # Get a slice as a new NDArray
>>> c = b.slice(slices)
>>> c.shape
(4, 10)