tensorstore.DimExpression.stride[self, strides: Sequence[int | None] | int | None] DimExpression

Strides the domains of the selected input dimensions by the specified amounts.

For each selected dimension i, the new domain is the set of indices x such that x * strides[i] is contained in the original domain.

Examples

>>> transform = ts.IndexTransform(input_inclusive_min=[0, 2, 1],
...                               input_inclusive_max=[6, 5, 8],
...                               input_labels=["x", "y", "z"])
>>> transform[ts.d["x", "z"].stride[-2, 3]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: [-3, 1) "x"
    1: [2, 6) "y"
    2: [1, 3) "z"
  Output index maps:
    out[0] = 0 + -2 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 3 * in[2]
>>> transform[ts.d["x", "z"].stride[3]]
Rank 3 -> 3 index space transform:
  Input domain:
    0: [0, 3) "x"
    1: [2, 6) "y"
    2: [1, 3) "z"
  Output index maps:
    out[0] = 0 + 3 * in[0]
    out[1] = 0 + 1 * in[1]
    out[2] = 0 + 3 * in[2]

Note

expr.stride[strides] is similar to the NumPy-style slicing operation expr[::strides] except that the striding is always done with respect to an origin of 0, irrespective of the existing dimension lower bounds.

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

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

Strides for each selected dimension. May also be a scalar, e.g. 2, in which case the same stride value is used for all selected dimensions. Specifying None for a given dimension (equivalent to specifying a stride of 1) leaves that dimension unchanged. Specify a stride of 0 is not valid.

Returns:

Dimension expression with the striding operation added.

Raises:

IndexError – If the number strides does not match the number of selected dimensions.