-
tensorstore_demo.IndexDomain.__getitem__(
self, other: IndexDomain
) -> IndexDomain Slices this domain by another domain.
The result is determined by matching dimensions of
otherto dimensions ofselfeither by label or by index, according to one of the following three cases:otheris entirely unlabeledResult is
self[ts.d[:][other.inclusive_min:other.exclusive_max]. It is an error ifself.rank != other.rank.selfis entirely unlabeledResult is
self[ts.d[:][other.inclusive_min:other.exclusive_max].labels[other.labels]. It is an error ifself.rank != other.rank.Both
selfandotherhave at least one labeled dimension.Result is
self[ts.d[dims][other.inclusive_min:other.exclusive_max], where the sequence ofother.rankdimension identifiersdimsis determined as follows:If
other.labels[i]is specified (i.e. non-empty),dims[i] = self.labels.index(other.labels[i]). It is an error if no such dimension exists.Otherwise,
iis thejth unlabeled dimension ofother(left to right), anddims[i] = k, wherekis thejth unlabeled dimension ofself(left to right). It is an error if no such dimension exists.
If any dimensions of
otherare unlabeled, then it is an error ifself.rank != other.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.IndexDomain(inclusive_min=[0, 1], exclusive_max=[5, 7]) >>> b = ts.IndexDomain(inclusive_min=[2, 3], exclusive_max=[4, 6]) >>> a[b] { [2, 4), [3, 6) }Example with fully labeled dimensions
>>> a = ts.IndexDomain(inclusive_min=[0, 1, 2], ... exclusive_max=[5, 7, 8], ... labels=["x", "y", "z"]) >>> b = ts.IndexDomain(inclusive_min=[2, 3], ... exclusive_max=[6, 4], ... labels=["y", "x"]) >>> a[b] { "x": [3, 4), "y": [2, 6), "z": [2, 8) }Example with mixed labeled and unlabeled dimensions
>>> a = ts.IndexDomain(inclusive_min=[0, 0, 0, 0], ... exclusive_max=[10, 10, 10, 10], ... labels=["x", "", "", "y"]) >>> b = ts.IndexDomain(inclusive_min=[1, 2, 3, 4], ... exclusive_max=[6, 7, 8, 9], ... labels=["y", "", "x", ""]) >>> a[b] { "x": [3, 8), [2, 7), [4, 9), "y": [1, 6) }Note
On
other, implicit bounds indicators have no effect.