class tensorstore.Unit

Specifies a physical quantity/unit.

The quantity is specified as the combination of:

  • A numerical multiplier, represented as a double-precision floating-point number. A multiplier of 1 may be used to indicate a quanity equal to a single base unit.

  • A base_unit, represented as a string. An empty string may be used to indicate a dimensionless quantity. In general, TensorStore does not interpret the base unit string; some drivers impose additional constraints on the base unit, while other drivers may store the specified unit directly. It is recommended to follow the udunits2 syntax unless there is a specific need to deviate.

Objects of this type are immutable.

Constructors

Unit(multiplier: float = 1)

Constructs a dimension-less quantity of the specified value.

Unit(unit: str)

Constructs a unit from a string.

Unit(multiplier: float, base_unit: str)

Constructs a unit from a multiplier and base unit.

Unit(unit: tuple[float, str])

Constructs a unit from a multiplier and base unit pair.

Unit(*, json: Any)

Constructs a unit from its JSON representation.

Accessors

multiplier : float

Multiplier for the base_unit.

base_unit : str

Base unit from which this unit is derived.

to_json() Any

Converts to the JSON representation.

Comparison operators

__eq__(other: Unit) bool

Compares two units for equality.

Arithmetic operators

__mul__(multiplier: float) Unit

Multiplies this unit by the specified multiplier.

__truediv__(divisor: float) Unit

Divides this unit by the specified divisor.