class tensorstore.Dim

1-d index interval with optionally-implicit bounds and dimension label.

Represents a contiguous range of integer index values. The inclusive lower and upper bounds may either be finite values in the closed interval \([-(2^{62}-2), +(2^{62}-2)]\), or infinite, as indicated by -/+ inf for the lower and upper bounds, respectively.

The lower and upper bounds may additionally be marked as either explicit or implicit.

The interval may also have an associated dimension label, which is primarily useful for specifying the dimensions of an IndexDomain.

Examples

>>> ts.Dim('x')
Dim(label="x")
>>> ts.Dim(inclusive_min=3, exclusive_max=10, label='x')
Dim(inclusive_min=3, exclusive_max=10, label="x")

See also

IndexDomain

Constructors

Dim(label: str | None = None, *, implicit_lower: bool = True, ...)

Constructs an unbounded interval (-inf, +inf).

Dim(size: int | None, label: str | None = None, *, ...)

Constructs a sized interval [inclusive_min, inclusive_min+size).

Dim(inclusive_min: int | None = -inf, ...)

Constructs a half-open interval [inclusive_min, exclusive_max).

Dim(*, inclusive_min: int | None = -inf, ...)

Constructs a closed interval [inclusive_min, inclusive_max].

Public members

intersect(other: Dim) Dim

Intersect with another Dim.

hull(other: Dim) Dim

Hull with another Dim.

Accessors

inclusive_min : int

Inclusive lower bound of the interval.

inclusive_max : int

Inclusive upper bound of the interval.

exclusive_min : int

Exclusive lower bound of the interval.

exclusive_max : int

Exclusive upper bound of the interval.

size : int

Size of the interval.

implicit_lower : bool

Indicates if the lower bound is implicit/resizeable.

implicit_upper : bool

Indicates if the upper bound is implicit/resizeable.

label : str

Dimension label, or the empty string to indicate an unlabeled dimension.

__len__() int

Size of the interval, equivalent to size.

empty : bool

Returns True if size is zero.

finite : bool

Indicates if the interval is finite.

Operations

__contains__(other: int) bool

Checks if the interval contains a given index.

__contains__(inner: Dim) bool

Checks if the interval contains another interval.

__iter__() Iterator

Enables iteration over the indices contained in the interval.

__eq__(other: Dim) bool

Compares for equality with another interval.

String representation

__str__() str

Returns the string representation of the interval.

__repr__() str

Returns the string representation as a Python expression.