Skip to main content

A collection of unit of measure.

Project description

metrum

PyPI version License: Apache-2.0

A collection of unit of measure.

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.

Reference Units

The library converts all units to a consistent set of reference units. The base units are the 7 SI base units, and the rest are SI derived units.

Quantity Unit Var. Name
Time second s
Length metre m
Mass kilogram kg
Electric current ampere A
Temperature kelvin K
Amount of substance mole mol
Luminous intensity candela cd
... and many more derived units ...

For each base unit, metrum also provides prefixed versions (pico, nano, micro, milli, centi, deci, deca, hetto, kilo, mega, giga, tera).

Special Units

Besides the SI units, metrum also supports a variety of special units, including:

  • Time: min, h, d
  • Length: au (astronomical unit), US Customary units (usc_in, usc_ft, usc_mi, etc.)
  • Mass: t (tonne), Da (dalton), US Customary units (usc_oz, usc_lb, etc.)
  • and many more.

For a complete list of all available units, see the metrum.units module documentation page.

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.

Author

Project Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrum-0.1.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metrum-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file metrum-0.1.0.tar.gz.

File metadata

  • Download URL: metrum-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for metrum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 71d240fd9ec3113f13aede3f9e815d39f10627c1a2f7a56960ab87375d554499
MD5 05823afc8895341a068765dc63ea60f2
BLAKE2b-256 0031b72323cfa08b827e8cf18112d3735de8897a7639cb443736d3c3323e8259

See more details on using hashes here.

File details

Details for the file metrum-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: metrum-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for metrum-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8be9cf5e0971983a4c54191c9f5081c689179568b274cf9cb65d73815936502e
MD5 8ee938371bd6b825a44738ae0a0921c1
BLAKE2b-256 13ada6ec3af6810bbb09a66d6bee499f32da2f95fa67cda8126ec01b50afa75c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page