plestylib.data.units#

Classes#

Units

Standardized unit expression parser and composer.

Module Contents#

class plestylib.data.units.Units(dims: Dict[str, int] | None = None, factor: float = 1.0)#

Standardized unit expression parser and composer.

The internal representation tracks: - dims: dimension exponents, e.g. {“L”: 1, “T”: -1} for speed - factor: numeric scaling factor to SI base units

Parameters:
  • dims (Optional[Dict[str, int]])

  • factor (float)

SYMBOLS#
BASE_SYMBOLS#
dims#
factor#
classmethod scalar() Units#
Return type:

Units

classmethod parse(unit_str: str | None) Units | None#
Parameters:

unit_str (Optional[str])

Return type:

Optional[Units]

classmethod standardize(unit_str: str | None) str | None#
Parameters:

unit_str (Optional[str])

Return type:

Optional[str]

compatible(other: Units) bool#
Parameters:

other (Units)

Return type:

bool

conversion_scale_to(target: Units) float#
Parameters:

target (Units)

Return type:

float

multiply(other: Units) Units#
Parameters:

other (Units)

Return type:

Units

divide(other: Units) Units#
Parameters:

other (Units)

Return type:

Units

power(exponent: int) Units#
Parameters:

exponent (int)

Return type:

Units

to_unit_string() str | None#
Return type:

Optional[str]