skillfed

unyt

A package for handling numpy arrays with units

unyt v3.1.0 99.2K downloads/30d#13,032 on PyPI382
Permissive license BSD-3-Clause Active released

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 unyt

uv

uv add unyt

poetry

poetry add unyt

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: Implementation :: CPython

Tags

numpy arrays with unitsunit conversion pythondimensional analysisphysical quantitiesunit handlingquantity arraysscientific data units
scientific-computingunit-conversiondata-validation

More Scientific/Engineering packages