blosc2.NDArray.__getitem__#

NDArray.__getitem__(key: int | slice | Sequence[slice] | LazyExpr | str) ndarray#

Get a (multidimensional) slice as specified in key.

Parameters:

key (int, slice, sequence of slices or LazyExpr) – The slice(s) to be retrieved. Note that step parameter is not honored yet in slices. If a LazyExpr is provided, the expression is supposed to be of boolean type and the result will be the values of this array where the expression is True. If the key is a string, it will be converted to a LazyExpr, and will search for the operands in the fields of this structured array.

Returns:

out – An array (or LazyExpr) with the requested data.

Return type:

np.ndarray | blosc2.LazyExpr

Examples

>>> import blosc2
>>> shape = [25, 10]
>>> # Create an array
>>> a = blosc2.full(shape, 3.3333)
>>> # Get slice as a NumPy array
>>> a[:5, :5]
array([[3.3333, 3.3333, 3.3333, 3.3333, 3.3333],
       [3.3333, 3.3333, 3.3333, 3.3333, 3.3333],
       [3.3333, 3.3333, 3.3333, 3.3333, 3.3333],
       [3.3333, 3.3333, 3.3333, 3.3333, 3.3333],
       [3.3333, 3.3333, 3.3333, 3.3333, 3.3333]])