tensorstore.Spec.update(self, *, open_mode: OpenMode | None = None, open: bool | None = None, create: bool | None = None, delete_existing: bool | None = None, assume_metadata: bool | None = None, assume_cached_metadata: bool | None = None, unbind_context: bool | None = None, strip_context: bool | None = None, context: Context | None = None, kvstore: KvStore.Spec | None = None, rank: int | None = None, dtype: dtype | None = None, domain: IndexDomain | None = None, shape: Sequence[int] | None = None, chunk_layout: ChunkLayout | None = None, codec: CodecSpec | None = None, fill_value: ArrayLike | None = None, dimension_units: Sequence[Unit | str | Real | tuple[Real, str] | None] | None = None, schema: Schema | None = None) None

Adds additional constraints or changes the open mode.

Example

>>> spec = ts.Spec({'driver': 'n5', 'kvstore': {'driver': 'memory'}})
>>> spec.update(shape=[100, 200, 300])
>>> spec
Spec({
  'driver': 'n5',
  'kvstore': {'driver': 'memory'},
  'schema': {
    'domain': {'exclusive_max': [100, 200, 300], 'inclusive_min': [0, 0, 0]},
  },
  'transform': {
    'input_exclusive_max': [[100], [200], [300]],
    'input_inclusive_min': [0, 0, 0],
  },
})
Parameters:
open_mode: OpenMode | None = None

Overrides the existing open mode.

open: bool | None = None

Allow opening an existing TensorStore. Overrides the existing open mode.

create: bool | None = None

Allow creating a new TensorStore. Overrides the existing open mode. To open or create, specify create=True and open=True.

delete_existing: bool | None = None

Delete any existing data before creating a new array. Overrides the existing open mode. Must be specified in conjunction with create=True.

assume_metadata: bool | None = None

Neither read nor write stored metadata. Instead, just assume any necessary metadata based on constraints in the spec, using the same defaults for any unspecified metadata as when creating a new TensorStore. The stored metadata need not even exist. Operations such as resizing that modify the stored metadata are not supported. Overrides the existing open mode. Requires that open is True and delete_existing is False. This option takes precedence over assume_cached_metadata if that option is also specified.

Warning

This option can lead to data corruption if the assumed metadata does not match the stored metadata, or multiple concurrent writers use different assumed metadata.

assume_cached_metadata: bool | None = None

Skip reading the metadata when opening. Instead, just assume any necessary metadata based on constraints in the spec, using the same defaults for any unspecified metadata as when creating a new TensorStore. The stored metadata may still be accessed by subsequent operations that need to re-validate or modify the metadata. Requires that open is True and delete_existing is False. The assume_metadata option takes precedence if also specified.

Warning

This option can lead to data corruption if the assumed metadata does not match the stored metadata, or multiple concurrent writers use different assumed metadata.

unbind_context: bool | None = None

Convert any bound context resources to context resource specs that fully capture the graph of shared context resources and interdependencies.

Re-binding/re-opening the resultant spec will result in a new graph of new context resources that is isomorphic to the original graph of context resources. The resultant spec will not refer to any external context resources; consequently, binding it to any specific context will have the same effect as binding it to a default context.

Specifying a value of False has no effect.

strip_context: bool | None = None

Replace any bound context resources and unbound context resource specs by default context resource specs.

If the resultant Spec is re-opened with, or re-bound to, a new context, it will use the default context resources specified by that context.

Specifying a value of False has no effect.

context: Context | None = None

Bind any context resource specs using the specified shared resource context.

Any already-bound context resources remain unchanged. Additionally, any context resources specified by a nested TensorStore.context spec will be created as specified, but won’t be overridden by context.

kvstore: KvStore.Spec | None = None

Sets the associated key-value store used as the underlying storage.

If the kvstore has already been set, it is overridden.

It is an error to specify this if the TensorStore driver does not use a key-value store.

rank: int | None = None

Constrains the rank of the TensorStore. If there is an index transform, the rank constraint must match the rank of the input space.

dtype: dtype | None = None

Constrains the data type of the TensorStore. If a data type has already been set, it is an error to specify a different data type.

domain: IndexDomain | None = None

Constrains the domain of the TensorStore. If there is an existing domain, the specified domain is merged with it as follows:

  1. The rank must match the existing rank.

  2. All bounds must match, except that a finite or explicit bound is permitted to match an infinite and implicit bound, and takes precedence.

  3. If both the new and existing domain specify non-empty labels for a dimension, the labels must be equal. If only one of the domains specifies a non-empty label for a dimension, the non-empty label takes precedence.

Note that if there is an index transform, the domain must match the input space, not the output space.

shape: Sequence[int] | None = None

Constrains the shape and origin of the TensorStore. Equivalent to specifying a domain of ts.IndexDomain(shape=shape).

Note

This option also constrains the origin of all dimensions to be zero.

chunk_layout: ChunkLayout | None = None

Constrains the chunk layout. If there is an existing chunk layout constraint, the constraints are merged. If the constraints are incompatible, an error is raised.

codec: CodecSpec | None = None

Constrains the codec. If there is an existing codec constraint, the constraints are merged. If the constraints are incompatible, an error is raised.

fill_value: ArrayLike | None = None

Specifies the fill value for positions that have not been written.

The fill value data type must be convertible to the actual data type, and the shape must be broadcast-compatible with the domain.

If an existing fill value has already been set as a constraint, it is an error to specify a different fill value (where the comparison is done after normalization by broadcasting).

dimension_units: Sequence[Unit | str | Real | tuple[Real, str] | None] | None = None

Specifies the physical units of each dimension of the domain.

The physical unit for a dimension is the physical quantity corresponding to a single index increment along each dimension.

A value of None indicates that the unit is unknown. A dimension-less quantity can be indicated by a unit of "".

schema: Schema | None = None

Additional schema constraints to merge with existing constraints.