unitflow.core¶
Dimensions, scales, units, quantities, and display resolution.
Semantic core exports for unitflow.
- class unitflow.core.Dimension(exponents)[source]¶
Bases:
objectImmutable exponent vector over the fixed base-dimension basis.
- Parameters:
exponents (tuple[int, ...])
- exponents: tuple[int, ...]¶
- classmethod base(name)[source]¶
Return a single base dimension by its canonical name.
- Parameters:
name (str)
- Return type:
- classmethod from_mapping(exponents_by_name)[source]¶
Construct a dimension vector from a sparse base-dimension mapping.
- Parameters:
exponents_by_name (dict[str, int])
- Return type:
- property is_dimensionless: bool¶
Whether all exponents are zero.
- class unitflow.core.Quantity(magnitude, unit)[source]¶
Bases:
objectConcrete magnitude plus semantic unit.
- Parameters:
magnitude (Any)
unit (Unit)
- magnitude: Any¶
- class unitflow.core.Scale(coefficient, pi_power=0)[source]¶
Bases:
objectExact scale represented as a rational coefficient times an integer power of pi.
- Parameters:
coefficient (Fraction)
pi_power (int)
- coefficient: Fraction¶
- pi_power: int¶
- classmethod from_ratio(numerator, denominator=1, *, pi_power=0)[source]¶
- Parameters:
numerator (int)
denominator (int)
pi_power (int)
- Return type:
- property is_zero: bool¶
- class unitflow.core.Unit(dimension, scale, name=None, symbol=None, aliases=(), family=None, quantity_kind=None)[source]¶
Bases:
objectImmutable semantic unit definition.
- Parameters:
dimension (Dimension)
scale (Scale)
name (str | None)
symbol (str | None)
aliases (tuple[str, ...])
family (UnitFamily | None)
quantity_kind (str | None)
- name: str | None¶
- symbol: str | None¶
- aliases: tuple[str, ...]¶
- family: UnitFamily | None¶
- quantity_kind: str | None¶
- classmethod dimensionless(*, name=None, symbol=None, aliases=(), family=None, quantity_kind=None)[source]¶
- Parameters:
name (str | None)
symbol (str | None)
aliases (tuple[str, ...])
family (UnitFamily | None)
quantity_kind (str | None)
- Return type:
- with_metadata(*, name=<object object>, symbol=<object object>, aliases=<object object>, family=<object object>, quantity_kind=<object object>)[source]¶
- Parameters:
name (str | None | object)
symbol (str | None | object)
aliases (tuple[str, ...] | None | object)
family (UnitFamily | None | object)
quantity_kind (str | None | object)
- Return type: