tensorstore.DimExpression.mark_bounds_implicit[self, implicit: bool | None | slice] DimExpression

Marks the lower/upper bounds of the selected dimensions as implicit/explicit.

For a TensorStore, implicit bounds indicate resizeable dimensions. Marking a bound as explicit fixes it to its current value such that it won’t be adjusted by subsequent TensorStore.resolve calls if the stored bounds change.

Because implicit bounds do not constrain subsequent indexing/slicing operations, a bound may be marked implicit in order to expand the domain.

Warning

Be careful when marking bounds as implicit, since this may bypass intended constraints on the domain.

Examples

>>> s = await ts.open({
...     'driver': 'zarr',
...     'kvstore': 'memory://'
... },
...                   shape=[100, 200],
...                   dtype=ts.uint32,
...                   create=True)
>>> s.domain
{ [0, 100*), [0, 200*) }
>>> await s.resize(exclusive_max=[200, 300])
>>> (await s.resolve()).domain
{ [0, 200*), [0, 300*) }
>>> (await s[ts.d[0].mark_bounds_implicit[False]].resolve()).domain
{ [0, 100), [0, 300*) }
>>> s_subregion = s[20:30, 40:50]
>>> s_subregion.domain
{ [20, 30), [40, 50) }
>>> (await
...  s_subregion[ts.d[0].mark_bounds_implicit[:True]].resolve()).domain
{ [20, 200*), [40, 50) }
>>> t = ts.IndexTransform(input_rank=3)
>>> t = t[ts.d[0, 2].mark_bounds_implicit[False]]
>>> t
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf, +inf)
    1: (-inf*, +inf*)
    2: (-inf, +inf)
  Output index maps:
    out[0] = 0 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> t = t[ts.d[0, 1].mark_bounds_implicit[:True]]
>>> t
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf, +inf*)
    1: (-inf*, +inf*)
    2: (-inf, +inf)
  Output index maps:
    out[0] = 0 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> t = t[ts.d[1, 2].mark_bounds_implicit[True:False]]
>>> t
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf, +inf*)
    1: (-inf*, +inf)
    2: (-inf*, +inf)
  Output index maps:
    out[0] = 0 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]

The new dimension selection is the same as the prior dimension selection.

Parameters:
implicit: bool | None | slice

Indicates the new implicit value for the lower and upper bounds. Must be one of:

  • None to indicate no change;

  • True to change both lower and upper bounds to implicit;

  • False to change both lower and upper bounds to explicit.

  • a slice, where start and stop specify the new implicit value for the lower and upper bounds, respectively, and each must be one of None, True, or False.

Returns:

Dimension expression with bounds marked as implicit/explicit.

Raises:

IndexError – If the resultant domain would have an input dimension referenced by an index array marked as implicit.