Welcome to metrum
metrum is a Python library that provides a simple and intuitive way to work
with units of measurement in your code. It helps improve code readability and
ensures consistency by converting all quantities to a standard set of reference
units (SI units).
Installation
You can install metrum using pip:
pip install metrum
Usage
Using metrum is straightforward. Import the units you need and use them in
your calculations.
from metrum.units import cm, g, usc_in
height = 180 * cm # cm = 0.01 * m, so height is 1.8 (meters)
weight = 250 * g # g = 0.001 * kg, so weight is 0.25 (kilograms)
width = 10 * usc_in # usc_in = 0.0254 * m, so width is 0.254 (meters)
print(f"Height: {height} m")
print(f"Weight: {weight} kg")
print(f"Width: {width} m")
This makes your code more explicit and easier to understand, as the units are clearly stated. All conversions are handled automatically, bringing the values to the base SI units.
For a complete list of all available units, please refer to the API documentation.
Contributing
Contributions are welcome! If you have a unit of measure you'd like to see added or want to improve the library in any other way, please feel free to open an issue or submit a pull request on our GitHub repository.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.