tensorstore_demo.DimExpression.label(
    
selflabels: str | collections.abc.Sequence[str]
-> DimExpression

Sets (or changes) the labels of the selected dimensions.

Examples

>>> ts.IndexTransform(3)[ts.d[0].label['x']]
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf*, +inf*) "x"
    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]
>>> ts.IndexTransform(3)[ts.d[0, 2].label['x', 'z']]
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf*, +inf*) "x"
    1: (-inf*, +inf*)
    2: (-inf*, +inf*) "z"
  Output index maps:
    out[0] = 0 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> ts.IndexTransform(3)[ts.d[:].label['x', 'y', 'z']]
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf*, +inf*) "x"
    1: (-inf*, +inf*) "y"
    2: (-inf*, +inf*) "z"
  Output index maps:
    out[0] = 0 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> ts.IndexTransform(3)[ts.d[0, 1].label['x', 'y'].translate_by[2]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: (-inf*, +inf*) "x"
    1: (-inf*, +inf*) "y"
    2: (-inf*, +inf*)
  Output index maps:
    out[0] = -2 + 1 * in[0]
    out[1] = -2 + 1 * in[1]
    out[2] = 0 + 1 * in[2]

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

Parameters:
labels: str | collections.abc.Sequence[str]

Dimension labels for each selected dimension.

Returns:

Dimension expression with the label operation added.

Raises:

IndexError – If the number of labels does not match the number of selected dimensions, or if the resultant domain would have duplicate labels.


Last update: Dec 16, 2024