Units#

Lightweight explicit SI conversion helpers. Public APIs document SI base units.

engineeringkit.units.convert(value, from_unit, to_unit)[source]#

Convert a length or pressure between units.

Parameters:
  • value (float) – Finite value in from_unit.

  • from_unit (str) – Unit names: m, mm, cm, km, in, ft for length, or Pa, kPa, MPa, bar, psi for pressure.

  • to_unit (str) – Unit names: m, mm, cm, km, in, ft for length, or Pa, kPa, MPa, bar, psi for pressure.

Returns:

value expressed in to_unit.

Return type:

float

Raises:

ValueError – If value is nonfinite or the units are unknown or of different quantities.

Notes

Use it to bring a value to SI before passing it to the package, whose inputs are raw SI numbers with no dimensional metadata.