Float-based unit conversion factors for consistent unit systems.
Every unit is a plain float equal to its conversion factor into a chosen consistent base system. Absolute SI values live in a single source of truth (_factors.py); a system factory derives a consistent set of float constants for any (length, force, time) triple. An opt-in baseUnits.checked submodule keeps a Quantity/Unit/Dimension runtime layer for safety-critical code.
| Quantity | Unit | Value |
|---|---|---|
| Length | mm | 1.0 |
| Force | N | 1.0 |
| Mass | tonne | 1.0 |
| Time | s | 1.0 |
| Pressure | MPa | 1.0 |
| g | gravity | 9806.65 |
All modules follow the <force>_<length>_<time> naming pattern.
baseUnits.systems.N_mm_s— N-mm-tonne-s (default)baseUnits.systems.N_m_s— N-m-kg-sbaseUnits.systems.kN_m_s— kN-m-tonne-sbaseUnits.systems.kip_in_s— kip-inches-sbaseUnits.systems.kgf_m_s— gravitational metric (mass derived = hyl)baseUnits.systems.tf_m_s— tonne-force metric (mass derived = 1000 hyl)baseUnits.systems.dyne_cm_s— CGS
from baseUnits import m, kN, MPa, g
length = 5 * m # 5000.0 (mm)
load = 100 * kN # 100000.0 (N)
stress = 30 * MPa # 30.0 (MPa)
weight = 80 * g # 80 * 9806.65 (mm/s^2 acceleration scale)from baseUnits.systems.kip_in_s import m, kN, ksi, BASE
print(BASE) # "kip-inches-s"
print(5 * m) # 196.85 (inches)For runtime checks that catch dimension mismatches, use baseUnits.checked:
from baseUnits.checked import Quantity, m, mm, K, C
q = 5 * m
print(q.to(mm).value) # 5000.0
print((1 * K).to(C).value) # 1.0Arithmetic on Quantity objects raises if you mix incompatible dimensions.
git clone https://github.com/nmorabowen/baseUnits.git
cd baseUnits
pip install -e .