Python library to convert, and perform math operations on values of particular units. Includes SI Base units, and non-standard units such as the ones adopted in the imperial system.
One goal of Axiompy was to have interchangable spellings, so that both british/american spellers can choose how they want to spell.
For example, metre
, and meter
are interchangable spellings.
pip install axiompy
from axiompy import Units
units = Units()
print(units.unit_convert(3 * units.metre, units.foot))
If you wanted to get the unit from a string instead of using the __attr__
, you can use Unit.unit()
from axiompy import Units
units = Units()
print(units.unit_convert(3 * units.unit("metre"), units.foot))
from axiompy import Units
units = Units()
value = Value(15, units.centimetre, units) # Create 15 centimetres
print(units.value_to_base(value)) # Convert the value to have the base unit of centimetres (metres)
>>> <Value (0.15 <Unit (metre)>)>