- tensorstore.TensorStore.__getitem__(self, transform: IndexTransform) TensorStore
Computes a virtual view using an explicit index transform.
Example
>>> dataset = await ts.open( ... { ... 'driver': 'zarr', ... 'kvstore': { ... 'driver': 'memory' ... } ... }, ... dtype=ts.uint32, ... shape=[70, 80], ... create=True) >>> transform = ts.IndexTransform( ... input_shape=[3], ... output=[ ... ts.OutputIndexMap(index_array=[1, 2, 3]), ... ts.OutputIndexMap(index_array=[5, 4, 3]) ... ]) >>> dataset[transform] TensorStore({ 'context': { 'cache_pool': {}, 'data_copy_concurrency': {}, 'memory_key_value_store': {}, }, 'driver': 'zarr', 'dtype': 'uint32', 'kvstore': {'driver': 'memory'}, 'metadata': { 'chunks': [70, 80], 'compressor': { 'blocksize': 0, 'clevel': 5, 'cname': 'lz4', 'id': 'blosc', 'shuffle': -1, }, 'dimension_separator': '.', 'dtype': '<u4', 'fill_value': None, 'filters': None, 'order': 'C', 'shape': [70, 80], 'zarr_format': 2, }, 'transform': { 'input_exclusive_max': [3], 'input_inclusive_min': [0], 'output': [{'index_array': [1, 2, 3]}, {'index_array': [5, 4, 3]}], }, }) >>> await dataset[transform].write([1, 2, 3]) >>> await dataset[1:6, 1:6].read() 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 equalself.rank
.
- Returns:¶
View of rank
transform.input_rank
and domainself.domain[transform]
.
This is the most general form of indexing, to which all other indexing methods reduce:
self[expr]
is equivalent toself[ts.IndexTransform(self.domain)[expr]]
self.oindex[expr]
is equivalent toself[ts.IndexTransform(self.domain).oindex[expr]]
self.vindex[expr]
is equivalent toself[ts.IndexTransform(self.domain).vindex[expr]]
In most cases it is more convenient to use one of those other indexing forms instead.