- tensorstore.IndexTransform.__getitem__(self, domain: IndexDomain) IndexTransform
Slices this index transform by another domain.
The result is determined by matching dimensions of
domain
to dimensions ofself.domain
either by label or by index, according to one of the following three cases:domain
is entirely unlabeledResult is
self[ts.d[:][domain.inclusive_min:domain.exclusive_max]
. It is an error ifself.input_rank != domain.rank
.self.domain
is entirely unlabeledResult is
self[ts.d[:][domain.inclusive_min:domain.exclusive_max].labels[domain.labels]
. It is an error ifself.input_rank != domain.rank
.Both
self.domain
anddomain
have at least one labeled dimension.Result is
self[ts.d[dims][domain.inclusive_min:domain.exclusive_max]
, where the sequence ofdomain.rank
dimension identifiersdims
is determined as follows:If
domain.labels[i]
is specified (i.e. non-empty),dims[i] = self.input_labels.index(domain.labels[i])
. It is an error if no such dimension exists.Otherwise,
i
is thej
th unlabeled dimension ofdomain
(left to right), anddims[i] = k
, wherek
is thej
th unlabeled dimension ofself
(left to right). It is an error if no such dimension exists.
If any dimensions of
domain
are unlabeled, then it is an error ifself.input_rank != domain.rank
. This condition is not strictly necessary but serves to avoid a discrepancy in behavior with normal domain alignment.Example with all unlabeled dimensions
>>> a = ts.IndexTransform(input_inclusive_min=[0, 1], ... input_exclusive_max=[5, 7]) >>> b = ts.IndexDomain(inclusive_min=[2, 3], exclusive_max=[4, 6]) >>> transform[domain] Rank 3 -> 3 index space transform: Input domain: 0: [1, 4) 1: [2, 5) 2: [3, 6) Output index maps: out[0] = 0 + 1 * in[0] out[1] = 0 + 1 * in[1] out[2] = 0 + 1 * in[2]
Example with fully labeled dimensions
>>> a = ts.IndexTransform(input_inclusive_min=[0, 1, 2], ... input_exclusive_max=[5, 7, 8], ... input_labels=["x", "y", "z"]) >>> b = ts.IndexDomain(inclusive_min=[2, 3], ... exclusive_max=[6, 4], ... labels=["y", "x"]) >>> transform[domain] Rank 3 -> 3 index space transform: Input domain: 0: [1, 4) 1: [2, 5) 2: [3, 6) Output index maps: out[0] = 0 + 1 * in[0] out[1] = 0 + 1 * in[1] out[2] = 0 + 1 * in[2]
Example with mixed labeled and unlabeled dimensions
>>> a = ts.IndexTransform(input_inclusive_min=[0, 0, 0, 0], ... input_exclusive_max=[10, 10, 10, 10], ... input_labels=["x", "", "", "y"]) >>> b = ts.IndexDomain(inclusive_min=[1, 2, 3, 4], ... exclusive_max=[6, 7, 8, 9], ... labels=["y", "", "x", ""]) >>> a[b] Rank 4 -> 4 index space transform: Input domain: 0: [3, 8) "x" 1: [2, 7) 2: [4, 9) 3: [1, 6) "y" Output index maps: out[0] = 0 + 1 * in[0] out[1] = 0 + 1 * in[1] out[2] = 0 + 1 * in[2] out[3] = 0 + 1 * in[3]
Note
On
domain
, implicit bounds indicators have no effect.