- tensorstore.IndexDomain.index_exp : tuple[slice, ...]
Equivalent NumPy-compatible
index expression
.The index expression consists of a
tuple
ofrank
slice
objects that specify the lower and upper bounds for each dimension, where an infinite bound in the domain corresponds to a bound ofNone
in theslice
object.The index expression can be used with this library as a NumPy-style indexing expression or to directly index a
NumPy array
.Example
>>> ts.IndexDomain(rank=2).index_exp (slice(None, None, None), slice(None, None, None)) >>> ts.IndexDomain(inclusive_min=[1, 2], exclusive_max=[5, 10]).index_exp (slice(1, 5, None), slice(2, 10, None)) >>> arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) >>> domain = ts.IndexDomain(inclusive_min=[0, 2], shape=[3, 2]) >>> arr[domain.index_exp] array([[3, 4], [8, 9]])
- Raises:¶
ValueError – If any finite bound in
inclusive_min
orexclusive_max
is negative. In this case the index expression would not actually NumPy-compatible since NumPy does not support actual negative indices, and instead interprets negative numbers as counting from the end.