tensorstore.TensorStore.__setitem__(self, transform: IndexTransform, source: TensorStore | ArrayLike) None

Synchronously writes using an explicit index transform.

This allows Python subscript assignment syntax to be used as a shorthand for self[transform].write(source).result().

Example

>>> dataset = ts.open({
...     'driver': 'zarr',
...     'kvstore': {
...         'driver': 'memory'
...     }
... },
...                   dtype=ts.uint32,
...                   shape=[70, 80],
...                   create=True).result()
>>> transform = ts.IndexTransform(
...     input_shape=[3],
...     output=[
...         ts.OutputIndexMap(index_array=[1, 2, 3]),
...         ts.OutputIndexMap(index_array=[5, 4, 3])
...     ])
>>> dataset[transform] = [1, 2, 3]
>>> dataset[1:6, 1:6].read().result()
array([[0, 0, 0, 0, 1],
       [0, 0, 0, 2, 0],
       [0, 0, 3, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint32)
Parameters:
transform: IndexTransform

Index transform, transform.output_rank must equal self.rank.

source: TensorStore | ArrayLike

Source array, broadcast-compatible with self.domain[transform] and with a data type convertible to self.dtype. May be an existing TensorStore or any ArrayLike, including a scalar.

Warning

When not using a transaction, the subscript assignment syntax always blocks synchronously on the completion of the write operation. When performing multiple, fine-grained writes, it is recommended to either use a transaction or use the asynchronous TensorStore.write interface directly.