blosc2.NDArray.__setitem__#

NDArray.__setitem__(key, value)#

Set a slice.

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

  • value (Py_Object Supporting the Buffer Protocol) – An object supporting the Buffer Protocol used to overwrite the slice.

Examples

>>> import blosc2
>>> # Create an array
>>> a = blosc2.full([8, 8], 3.3333)
>>> # Set a slice to 0
>>> a[:5, :5] = 0
>>> a[:]
array([[0.    , 0.    , 0.    , 0.    , 0.    , 3.3333, 3.3333, 3.3333],
       [0.    , 0.    , 0.    , 0.    , 0.    , 3.3333, 3.3333, 3.3333],
       [0.    , 0.    , 0.    , 0.    , 0.    , 3.3333, 3.3333, 3.3333],
       [0.    , 0.    , 0.    , 0.    , 0.    , 3.3333, 3.3333, 3.3333],
       [0.    , 0.    , 0.    , 0.    , 0.    , 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, 3.3333, 3.3333]])