unyt
A package for handling numpy arrays with units
What it is and what it does
unyt is a NumPy array subclass that carries unit information alongside numerical data. Instead of writing plain NumPy arrays and relying on documentation or convention to track what units apply, you attach units directly to the array: `distance = [3.4, 5.8, 7.2] * u.mile` then convert or inspect units as needed. The package handles unit arithmetic, conversion between compatible units, and propagation through operations.
It's built entirely in Python on top of numpy and sympy, with no compiled dependencies or external tools required. The design keeps units transparent—operations on unitful arrays generally preserve or correctly combine units—so you can write scientific code that's both explicit about dimensions and readable.
Use it for:
- Track physical quantities in simulations or data analysis without losing dimensional information.
- Convert between unit systems (e.g., miles to kilometers) without manual lookup tables.
- Catch unit mismatches early by letting NumPy operations fail when incompatible units are combined.
- Document and enforce dimensional consistency in scientific workflows and research code.
- Build libraries that accept and return quantities with explicit units, reducing API ambiguity.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Attaches units to NumPy arrays and provides unit conversion, so you can track and transform dimensional data without losing track of what units you're working with.
Yes. unyt is a mature, actively maintained package with no security issues, low install friction, and a permissive license. It solves a real problem—tracking units in numerical code—that becomes increasingly valuable as data complexity grows. Install it if you work with physical quantities or dimensional data and want to avoid silent unit errors.
Install
unyt on PyPI
pip
pip install unytuv
uv add unytpoetry
poetry add unytInstalling unyt
Before you install
Low friction install with a pure-Python implementation depending only on numpy, sympy, and packaging. Active maintenance with a recent release and no known vulnerabilities.
License in practice
BSD 3-Clause permissive license allows use in commercial and proprietary projects with minimal restrictions; you must include a copy of the license and acknowledge the authors.
Quickstart
pip install unyt
import unyt as u
import numpy as np
distance = np.array([3.4, 5.8, 7.2]) * u.mile
print(distance.to('km'))
Requires Python 3.10 or later.
Verify before relying
- Whether unit conversion accuracy and precision meet domain-specific requirements for your application.
- Performance characteristics when working with very large arrays or frequent unit conversions.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, sympy, packaging |
| Maintenance | actively maintained — 211 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 99,246/month — #13,032 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: unyt-3.1.0-py3-none-any.whl
Keywords: unyt
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
pint-xarrayAdds physical units support to xarray datasets…
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
ansys-unitsManages physical quantities with numerical…
permissive · top 15,000 on PyPI
ucumvertParses UCUM (Unified Code for Units of Measure)…
permissive · top 15,000 on PyPI
quantitiesQuantities handles arithmetic and unit…
unclear · top 15,000 on PyPI
Pint-PandasPint-Pandas adds physical unit support to…
permissive · top 15,000 on PyPI
quantulum3Extracts quantities, measurements, and their…
permissive · top 15,000 on PyPI
hepunitsProvides units and physical constants in the…
permissive · top 15,000 on PyPI
binaryConverts between binary (IEC) and decimal (SI)…
permissive · top 15,000 on PyPI