blosc2.NDArray.__setitem__#
- NDArray.__setitem__(key: int | slice | Sequence[slice], value: object)#
Set a slice of the array.
- Parameters:
key¶ (int, slice or sequence of slices) – The index or indices specifying the slice(s) to be updated. Note that the step parameter is not yet supported.
value¶ (Py_Object Supporting the Buffer Protocol) – An object supporting the Buffer Protocol which will be used to overwrite the specified slice(s).
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]])