tensorstore.Unit(unit: str)

Constructs a unit from a string.

If the string contains a leading number, it is parsed as the multiplier and the remaining portion, after stripping leading and trailing whitespace, is used as the base_unit. If there is no leading number, the multiplier is 1 and the entire string, after stripping leading and trailing whitespace, is used as the base_unit.

Example

>>> ts.Unit('4nm')
Unit(4, "nm")
>>> ts.Unit('nm')
Unit(1, "nm")
>>> ts.Unit('3e5')
Unit(300000, "")
>>> ts.Unit('')
Unit(1, "")