Metronos
Metronos (from the Ancient Greek μέτρον /metron/, meaning "measure" or "that by which anything is measured.")
A lightweight Python library for physical quantities with units. No heavy dependencies, no mandatory annotations, no user-facing registries — just quantities that know what they are and refuse to let you mix them up.
Installation
pip install git+https://github.com/cgburnsi/Metronos.git
Or clone and install locally:
git clone https://github.com/cgburnsi/Metronos.git
cd Metronos
pip install -e .
Quick start
import metronos as mt
d = mt.Quantity(6.2, 'ft')
v = mt.Quantity(60, 'mile/s')
a = mt.Quantity(9.81, 'm/s^2')
Features
Unit conversion
mt.Quantity(6.2, 'ft').to('m') # Quantity(1.88976 [m])
mt.Quantity(60, 'mile/s').to('km/s') # Quantity(96.56064 [km/s])
mt.Quantity(9.81, 'm/s^2').to('ft/s^2') # Quantity(32.185 [ft/s^2])
Arithmetic
Units combine automatically. Mixed-unit arithmetic works as long as the dimensions are compatible.
mt.Quantity(100, 'm') + mt.Quantity(0.5, 'km') # Quantity(600.0 [m])
mass = mt.Quantity(70, 'kg')
accel = mt.Quantity(9.81, 'm/s^2')
force = mass * accel # Quantity(686.7 [m*kg/s^2])
KE = 0.5 * mass * mt.Quantity(10, 'm/s') ** 2 # Quantity(3500.0 [m^2*kg/s^2])
Temperature
Offset units (°C, °F, °R) are fully supported.
mt.Quantity(100, 'degC').to('degF') # Quantity(212.0 [degF])
mt.Quantity(32, 'degF').to('K') # Quantity(273.15 [K])
Extracting values
speed = mt.Quantity(25, 'm/s')
speed.to('km/s').value # 0.025 (float, in the requested unit)
ratio = mt.Quantity(3.0) / mt.Quantity(1.5)
float(ratio) # 2.0 (dimensionless quantities only)
Dimension safety
Metronos raises a DimensionError if you try to add or compare incompatible quantities.
mt.Quantity(1, 'm') + mt.Quantity(1, 'kg') # DimensionError
mt.Quantity(1, 'm').to('s') # DimensionError
mt.Quantity(1, 'm') < mt.Quantity(1, 'kg') # DimensionError
Comparisons
mt.Quantity(100, 'm') == mt.Quantity(0.1, 'km') # True
mt.Quantity(100, 'm') < mt.Quantity(1, 'mile') # True
Supported units
SI base units
| Symbol | Quantity |
|---|---|
m |
length |
g |
mass (base unit is kg internally) |
s |
time |
A |
electric current |
K |
temperature |
mol |
amount of substance |
cd |
luminous intensity |
All SI base and derived units support the full prefix set (n, µ, m, k, M, G, etc.).
Derived SI units
Hz, N, Pa, J, W, C, V, Ω, S, F, T, Wb, H, lm, lx, Bq, Gy, Sv, kat, L
Customary US units
ft, in, inch, mile, yard, lb, lbf, psi, psia, gal, BTU, degF, degR
Other
bar, Torr, min, h, degC
Philosophy
- Lean: No dependencies beyond the Python standard library.
- Pythonic: Clean, simple API with no mandatory annotations or boilerplate.
- Intuitive: It handles the dimensional math so you can focus on the physics.
Metadata
Release files for metronos 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metronos-0.1.1.tar.gz | 7.9 kB | Without provenance | Details for metronos-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metronos-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for metronos-0.1.1-py3-none-any.whl |
Total release size: 14.6 kB
Release files / metronos-0.1.1.tar.gz
| Download URL | metronos-0.1.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d25b73fc2e80655f1ad49b193c27ae570f4b43a04a5c2f98ff12b68503f7319
|
|
BLAKE2b-256 checksum How to use checksums |
166fe7fc210caac3ee265399f81db33d501457b57fc7db0092674a620d71d417
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / metronos-0.1.1-py3-none-any.whl
| Download URL | metronos-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e176f93c025e1083a1af0293b58e15a37daa342daf6bc9f3d673d2faeacabfd1
|
|
BLAKE2b-256 checksum How to use checksums |
52bd2a156ee391d5f3f20d4e5300d475509cad606f9c99355a90a93e0093f26c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for metronos 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.