Skip to main content

Units of Measure

as defined in Unit of Measurement.

Objectives

  1. Relate units of measure to the International System of Units (SI) to define their dimension and magnitude.
  2. Relate objects to units without changing the objects.
  3. Get the unit that an object is mapped to.
  4. Give units human-readable symbols and names, and computable attributes.
  5. Being mapped to a unit shall not keep an object from being garbage-collected.
  6. Provide SI units and prefixes.

Motivation

First, I used the library forallpeople, but that ran into issues with large scales like megatonnes and gigatonnes.

Based on my objectives I decided to create a new library that does exactly that and does not deal with quantities (yet).

Limits

Some types of objects like int and float cannot be mapped to units, because that would create error-prone states.

Not all accepted SI units are implemented.

Get Started

To start from the beginning, open the Jupyter notebook start_here.ipynb. This link is relative, so it might not work in all contexts.

There is no dependency to the package jupyter, neither at buildtime nor at runtime. Consequently this library does not declare jupyter as dependency. You can view the notebook on GitHub or in Visual Studio Code. Beyond that there are several alternatives to view notebooks. If you want to run or edit it, then you need something like package jupyter or Miniconda.

Download and install the library with python -m pip install units-of-measure.

Develop

  1. Clone with git clone https://github.com/gerald-scharitzer/units-of-measure.git
  2. Set up with python -m pip install -r requirements.txt
  3. Test with pytest
  4. Document with pydoc -w unitsofmeasure
  5. Build with python -m build
  6. Check with python -m twine check dist/*
  7. Publish with python -m twine upload dist/*

Release Notes

Release 1.2

Release 1.1

  • totally ordered prefixes
  • type and value checks in constructors
  • dimension symbols and names
  • pyproject.toml and hatchling instead of setuptools

Release files for units-of-measure 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for units-of-measure 1.2.0
File Size Uploaded
units_of_measure-1.2.0.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for units-of-measure 1.2.0
File Interpreter ABI Platform
units_of_measure-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / units_of_measure-1.2.0.tar.gz

Download URL units_of_measure-1.2.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
236f8d8ec5840beccbe5ed5513c126f126d573ed2f63ac1ae2f4c15e03cff319
BLAKE2b-256 checksum
How to use checksums
1093af1a4e725ffc6037e9d7c8efe9b6398d8a101408c4524106aa9f0c91352a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / units_of_measure-1.2.0-py3-none-any.whl

Download URL units_of_measure-1.2.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83f818511610ead6263871ab25d919cbd9a1670448e47f48e5989c43eea14567
BLAKE2b-256 checksum
How to use checksums
c6a8cd3e5f84a7c474ca8a493ed6ea0cc371226da61ebfac9c165edcdb737343
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page