tensorstore.DimExpression.translate_to[self, origins: Sequence[int | None] | int | None] DimExpression

Translates the domains of the selected input dimensions to the specified origins without affecting the output range.

Examples

>>> transform = ts.IndexTransform(input_shape=[4, 5, 6],
...                               input_labels=['x', 'y', 'z'])
>>> transform[ts.d['x', 'y'].translate_to[10, 20]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: [10, 14) "x"
    1: [20, 25) "y"
    2: [0, 6) "z"
  Output index maps:
    out[0] = -10 + 1 * in[0]
    out[1] = -20 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> transform[ts.d['x', 'y'].translate_to[10, None]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: [10, 14) "x"
    1: [0, 5) "y"
    2: [0, 6) "z"
  Output index maps:
    out[0] = -10 + 1 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 1 * in[2]
>>> transform[ts.d['x', 'y'].translate_to[10]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: [10, 14) "x"
    1: [10, 15) "y"
    2: [0, 6) "z"
  Output index maps:
    out[0] = -10 + 1 * in[0]
    out[1] = -10 + 1 * in[1]
    out[2] = 0 + 1 * in[2]

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

Parameters:
origins: Sequence[int | None] | int | None

The new origins for each of the selected dimensions. May also be a scalar, e.g. 5, in which case the same origin is used for all selected dimensions. If None is specified for a given dimension, the origin of that dimension remains unchanged.

Returns:

Dimension expression with the translation operation added.

Raises:
  • IndexError – If the number origins does not match the number of selected dimensions.

  • IndexError – If any of the selected dimensions has a lower bound of -inf.