quantities
Support for physical quantities with units, based on numpy
What it is and what it does
Quantities is a Python library for working with physical quantities—numbers paired with units and dimensionality. It extends numpy to let you perform arithmetic on quantities while automatically tracking and enforcing dimensional consistency; dividing distance by time yields a velocity with the correct units, and attempting to add incompatible units raises an error. The library is built on numpy and integrates with many numpy ufuncs, making it suitable for scientific and engineering calculations where unit safety matters.
The package is actively maintained and has a stable API, but the authors explicitly note that test coverage is incomplete and recommend against mission-critical applications. It depends only on numpy and installs as a pure Python wheel with low friction.
Use it for:
- Perform dimensional analysis in physics or engineering simulations where unit mismatches should be caught automatically.
- Convert between unit systems (e.g., metres to feet, seconds to hours) while preserving quantity semantics.
- Build scientific data pipelines where quantities carry both magnitude and dimensionality through calculations.
- Validate physical calculations by ensuring operations respect dimensional consistency rules.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Quantities handles arithmetic and unit conversions for physical quantities with magnitude, dimensionality, and optional uncertainty, built on numpy.
Yes, if you need unit-aware arithmetic in scientific code and can tolerate incomplete test coverage. The low install friction, active maintenance, and numpy integration make it straightforward to adopt. No, if your work is mission-critical or requires bulletproof test coverage—the package's own documentation discourages such use. Verify the license terms before committing.
Install
quantities on PyPI
pip
pip install quantitiesuv
uv add quantitiespoetry
poetry add quantitiesInstalling quantities
Before you install
Low install friction; pure Python wheel. Maintenance is active with recent commits, though the package notes test coverage remains incomplete and is not recommended for mission-critical applications.
License in practice
License treatment is unclear—the package states it uses only BSD-compatible code but provides no explicit SPDX identifier or raw license field in metadata, so you should verify the actual license terms before use.
Quickstart
pip install quantities
import quantities as pq
distance = 42 * pq.metre
time = 17 * pq.second
velocity = distance / time
print(f"{velocity.magnitude:.3f} {velocity.dimensionality}")
Requires Python >= 3.10 and numpy as a runtime dependency.
Verify before relying
- Whether test coverage has improved since the description was written and whether the package is now suitable for mission-critical use.
- Exact BSD license variant(s) used, given the unclear license_treatment in metadata.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 210 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 263,593/month — #8,354 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: quantities-0.16.4-py3-none-any.whl
Keywords: quantities, units, physical, constants
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
isqxisqx provides type-annotation-friendly metadata…
permissive · top 15,000 on PyPI
PintPint defines, operates on, and converts between…
permissive · top 5,000 on PyPI
typedunitsImplements unit of measurement arithmetic with…
permissive · top 15,000 on PyPI
quantulum3Extracts quantities, measurements, and their…
permissive · top 15,000 on PyPI
ansys-unitsManages physical quantities with numerical…
permissive · top 15,000 on PyPI
measurementProvides unit-aware measurement objects for…
permissive · top 5,000 on PyPI
Pint-PandasPint-Pandas adds physical unit support to…
permissive · top 15,000 on PyPI
pint-xarrayAdds physical units support to xarray datasets…
permissive · top 15,000 on PyPI
unytAttaches units to NumPy arrays and provides…
permissive · top 15,000 on PyPI
hepunitsProvides units and physical constants in the…
permissive · top 15,000 on PyPI