watlowlib.units¶
to_pint(unit) — maps a watlowlib.Unit (or a recognised alias
string) to a pint-compatible unit string. pint is not a runtime
dependency of watlowlib; this helper returns plain strings so
downstream tools that use pint can feed them straight into
pint.UnitRegistry.parse_expression, while consumers that don't use
pint can ignore the output. Lossy by design: gauge/absolute and other
distinctions pint doesn't model are dropped.
Public surface¶
watlowlib.units ¶
Pint-compatible unit-string export.
:func:to_pint maps a :class:watlowlib.Unit (or a recognised alias
string) into a pint-compatible unit string. pint itself is not
a runtime dependency of :mod:watlowlib — this helper returns plain
strings so downstream tools that use pint can feed them straight into
pint.UnitRegistry.parse_expression, while consumers that don't
use pint can ignore the output.
Lossy by design: if a unit has gauge/absolute or any other
distinction pint doesn't model, the loss is accepted — :func:to_pint
returns the lossy string. Callers that need the disambiguator handle
it themselves.
The mapping table here mirrors the table that previously lived in
capa/src/capa/devices/watlow.py. Moving it into :mod:watlowlib
means every consumer (capa, the in-house dashboards, downstream
clients) shares one source of truth.
to_pint ¶
Return a pint-compatible unit string.
Accepts a :class:Unit, a case-insensitive string alias, or
None. Returns:
NonewhenunitisNoneor when a string alias is unrecognised (lossy by design — callers that care distinguishNonethemselves)."degC"/"degF"/"percent"for the three Watlow units.
String inputs go through :func:watlowlib.registry.units.coerce_unit
so capitalisation and the common aliases ("C", "celsius",
"degC", "°C", ...) all map the same way as the rest of
the library.