pyunitwizard.standardize#
- pyunitwizard.standardize(quantity_or_unit, to_form=None, to_unit=None)[source]#
Convert a quantity or unit to standard units.
- Parameters:
quantity_or_unit (QuantityOrUnit) – The quantity or a unit that will be converted.
to_form (str, optional.) – The form to transform to. When omitted the configured default form is used.
to_unit (str, optional.) – Target unit expressed as a string (e.g.
"ms","angstrom"). When provided the output is converted to this unit instead of the configured standard unit for the corresponding dimensionality. The form standardization controlled by to_form still applies.
- Returns:
The quantity or unit converted to standard (or requested) units.
- Return type:
QuantityOrUnit
- Raises:
NoStandardsError – If no standard units were defined and to_unit was not supplied.