cast Driver

Virtual read/write view that performs element-wise data type conversion.

  • Reading is supported if the base TensorStore supports reading and conversion from the base data type to the view data type is supported.

  • Writing is supported if the base TensorStore supports writing and conversion from the view data type to the base data type is supported.

The top-level transform, if any, is composed with the TensorStore.transform, if any, specified on base.

json driver/cast : object
Extends:
Required members:
driver : "cast"
dtype : dtype

Specifies the data type under which to view the base TensorStore.

base : TensorStore | KvStore | TensorStoreUrl

Base TensorStore to adapt.

If a KvStore or KvStoreUrl is specified, the auto driver is used implicitly to auto-detect the format.

Optional members:
context : Context

Specifies context resources that augment/override the parent context.

rank : integer[0, 32]

Specifies the rank of the TensorStore.

If transform is also specified, the input rank must match. Otherwise, the rank constraint applies to the driver directly.

transform : IndexTransform

Specifies a transform.

schema : Schema

Specifies constraints on the schema.

When opening an existing array, specifies constraints on the existing schema; opening will fail if the constraints do not match. Any soft constraints specified in the chunk_layout are ignored. When creating a new array, a suitable schema will be selected automatically based on the specified schema constraints in combination with any driver-specific constraints.

Example

{
  "driver": "cast",
  "dtype": "int32",
  "base": {"driver": "zarr", "kvstore": {"driver": "gcs", "bucket": "my-bucket"}}
}
json TensorStoreUrl/cast : string

cast: TensorStore URL scheme

Data type conversion may be specified using the cast:dtype URL syntax.

Examples

URL representation

JSON representation

"file:///tmp/dataset.zarr/|zarr3:|cast:uint32"

{"driver": "cast",
 "dtype": "uint32",
 "base": {"driver": "zarr3",
          "kvstore": {"driver": "file",
                      "path": "/tmp/dataset.zarr/"}}
}
Extends: