pyunitwizard.dialects.ucum.validate_unit#
- pyunitwizard.dialects.ucum.validate_unit(unit, code, *, units_metadata=None)[source]#
Verify and emit an explicit UCUM code for unchanged computing values.
- Parameters:
unit (str or pint.Unit) – Computing unit verified against PyUnitWizard’s dedicated registry.
code (str) – Caller-negotiated, case-sensitive UCUM code, retained verbatim.
units_metadata (str, optional) – Required for temperatures:
temperature: on_scaleortemperature: difference. Difference computing units must have zero offset.
- Returns:
The checked code. This operation never guesses a canonical spelling.
- Return type:
str
- Raises:
RecordError – For unsupported syntax/semantics or different dimensions, scale or offset (relative tolerance 1e-12). Quantity kinds are never inferred.
ModuleNotFoundError – If the optional ucumvert provider is unavailable.
Examples
>>> validate_unit('nanomolar', 'nmol/L') 'nmol/L'