units-calculator
A simple units python calculator optimized for convenience over performance.
Basic usage
Parsing units
Usage example 1 - solving a basic kinematic problem
A ball is thrown upwards (from the ground) at a vertical speed of 40.5 feet per second and a horizontal speed of 20 km/h. How far away will it land, it meters?
from units_calculator.all import parse
vertical_velocity = parse("40.5ft/s")
gravitational_acceleration = parse("-9.8m/s^2")
horizontal_velocity = parse("20km/h")
time_to_peak = -vertical_velocity / gravitational_acceleration
time_to_land = 2 * time_to_peak
horizontal_displacement = horizontal_velocity * time_to_land
print(horizontal_displacement.as_units('m')) # 13.995918367346937m
Usage example 2 - solutions dilution
Lets say you are in a lab, and you need to perform some solution concentration comparison. In this curernt example you have 5 micrograms of some material, and you need to dilute it to 20 millimolar (mM) concentration, given a molecular mass of 544.43 grams per mol. What volume of solvent do you need to use?
from units_calculator.all import parse
dissolved_mass = parse("5mg")
target_concentration = parse("20mM")
molar_mass = parse("544.43g/mol")
dissolved_mols = dissolved_mass / molar_mass
solvent_volume = dissolved_mols / target_concentration
print(solvent_volume.as_units("ul"))
Creating dimensional quantities explicitly
from units_calculator.all import Meters, Seconds
_5m = Meters(5)
_3s = Seconds(3.0)
Defining custom units
TBD
List of supported units
TBD
Metadata
Release files for units-calculator 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| units-calculator-1.0.4.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| units_calculator-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.0 kB
Release files / units-calculator-1.0.4.tar.gz
| Download URL | units-calculator-1.0.4.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df30a307e35a1c4c0ef79b9101e2dd07437ba238e03f87537dbf82eea6272dc1
|
|
BLAKE2b-256 checksum How to use checksums |
56b4583456364d0ab1acbf0e0ee96266f4890f46e2c8c6aa3174f69fc1818804
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.8
|
Release files / units_calculator-1.0.4-py3-none-any.whl
| Download URL | units_calculator-1.0.4-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
21c2e7d247e1bbbb5932362fe6bbbe9b79002fd73d862d4071d872533786ca5f
|
|
BLAKE2b-256 checksum How to use checksums |
326dff987ca47e0020a3f66533a06303bc13c6006f486904243d89e26e43d1af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.8
|