- class tensorstore.TensorStore
Asynchronous multi-dimensional array handle.
Examples
>>> dataset = await ts.open( ... { ... 'driver': 'zarr', ... 'kvstore': { ... 'driver': 'memory' ... }, ... }, ... dtype=ts.uint32, ... shape=[1000, 20000], ... create=True) >>> dataset TensorStore({ 'context': { 'cache_pool': {}, 'data_copy_concurrency': {}, 'memory_key_value_store': {}, }, 'driver': 'zarr', 'dtype': 'uint32', 'kvstore': {'driver': 'memory'}, 'metadata': { 'chunks': [1000, 1049], 'compressor': { 'blocksize': 0, 'clevel': 5, 'cname': 'lz4', 'id': 'blosc', 'shuffle': -1, }, 'dimension_separator': '.', 'dtype': '<u4', 'fill_value': None, 'filters': None, 'order': 'C', 'shape': [1000, 20000], 'zarr_format': 2, }, 'transform': { 'input_exclusive_max': [[1000], [20000]], 'input_inclusive_min': [0, 0], }, }) >>> await dataset[5:10, 6:8].write(42) >>> await dataset[0:10, 0:10].read() array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 42, 42, 0, 0], [ 0, 0, 0, 0, 0, 0, 42, 42, 0, 0], [ 0, 0, 0, 0, 0, 0, 42, 42, 0, 0], [ 0, 0, 0, 0, 0, 0, 42, 42, 0, 0], [ 0, 0, 0, 0, 0, 0, 42, 42, 0, 0]], dtype=uint32)
Accessors¶
- domain : IndexDomain
Domain of the array.
-
spec(*, open: bool | None =
None
, ...) Spec Spec that may be used to re-open or re-create the TensorStore.
- chunk_layout : ChunkLayout
Chunk layout of the TensorStore.
- fill_value : ArrayLike | None
Fill value for positions not yet written.
- dimension_units : tuple[Unit | None, ...]
Physical units of each dimension of the domain.
Data type¶
- astype(dtype: dtype) TensorStore
Returns a read/write view as the specified data type.
I/O¶
- write(source: TensorStore | ArrayLike) WriteFutures
Writes to the current domain.
- resize(...) Future[TensorStore]
Resizes the current domain, persistently modifying the stored representation.
-
__array__(dtype: numpy.dtype | None =
None
, ...) ArrayLike Automatic conversion to
numpy.ndarray
for interoperability with NumPy.
-
resolve(fix_resizable_bounds: bool =
False
) Future[TensorStore] Obtains updated bounds, subject to the cache policy.
- __setitem__(transform: IndexTransform, source) None
Synchronously writes using an explicit index transform.
- __setitem__(transform: IndexDomain, source) None
Synchronously writes using an explicit index domain.
- __setitem__(transform: DimExpression, source) None
Synchronously writes using a dimension expression.
- __setitem__(indices: NumpyIndexingSpec, source) None
Synchronously writes using NumPy-style indexing with default index array semantics.
- oindex.__setitem__(indices: NumpyIndexingSpec, source)
Synchronously writes using NumPy-style indexing with outer indexing semantics.
- vindex.__setitem__(indices: NumpyIndexingSpec, source)
Synchronously writes using NumPy-style indexing with vectorized indexing semantics.
Transactions¶
- transaction : Transaction | None
Associated transaction used for read/write operations.
- with_transaction(transaction: Transaction | None) TensorStore
Returns a transaction-bound view of this TensorStore.
Indexing¶
- __getitem__(transform: IndexTransform) TensorStore
Computes a virtual view using an explicit index transform.
- __getitem__(domain: IndexDomain) TensorStore
Computes a virtual view using an explicit index domain.
- __getitem__(expr: DimExpression) TensorStore
Computes a virtual view using a dimension expression.
- __getitem__(indices: NumpyIndexingSpec) TensorStore
Computes a virtual view using NumPy-style indexing with default index array semantics.
- oindex[indices: NumpyIndexingSpec] TensorStore
Computes a virtual view using NumPy-style indexing with outer indexing semantics.
- vindex[indices: NumpyIndexingSpec] TensorStore
Computes a virtual view using NumPy-style indexing with vectorized indexing semantics.
- T : TensorStore
View with transposed domain (reversed dimension order).