English

unyt: Handle, manipulate, and convert data with units in Python

Instrumentation and Methods for Astrophysics 2018-10-03 v3

Abstract

Software that processes real-world data or that models a physical system must have some way of managing units. While simple approaches like the understood convention that all data are in a unit system (such as the MKS SI unit system) do work in practice, they are fraught with possible sources of error both by developers and users of the software. In this paper we present unyt, a Python library based on NumPy and SymPy for handling data that has units. It is designed both to aid quick interactive calculations and to be tightly integrated into a larger Python application or library. We compare unyt with two other Python libraries for handling units, Pint and astropy.units, and find that unyt is faster, has higher test coverage, and has fewer lines of code.

Keywords

Cite

@article{arxiv.1806.02417,
  title  = {unyt: Handle, manipulate, and convert data with units in Python},
  author = {Nathan J. Goldbaum and John A. ZuHone and Matthew J. Turk and Kacper Kowalik and Anna L. Rosen},
  journal= {arXiv preprint arXiv:1806.02417},
  year   = {2018}
}

Comments

11 pages, 6 figures. Submitted to the Journal of Open Source Software. The source code is available at https://github.com/yt-project/unyt and the documentation is available at http://unyt.readthedocs.io/en/latest/. Accepted for publication in the Journal of Open Source Software

R2 v1 2026-06-23T02:21:47.157Z