Skip to content

Perform operations and conversions on units and values.

License

Notifications You must be signed in to change notification settings

ArztKlein/Axiompy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPI - Downloads PyPI

Axiompy

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.

Interchangable spellings

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.

Installation

pip install axiompy

Usage

Convert between units

from axiompy import Units
units = Units()
print(units.unit_convert(3 * units.metre, units.foot))

Get Unit from String

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))

Convert value to its base value

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)>)>

Releases

No releases published

Packages

No packages published

Languages