English

Physical-type correctness in scientific Python

Mathematical Software 2018-08-06 v3

Abstract

The representation of units and dimensions in informatics systems is barely codified and often ignored. For instance, the major languages used in scientific computing (Fortran, C and Python), have no type for dimension or unit, and so physical quantities are represented in a program by variables of type real, resulting in the possibility of unit or dimensional errors. In view of this danger, many authors have proposed language schemes for unit-checking and conversion. However, since many physical quantities have the same units, it is possible for a block of code to be unit-compatible, but still physically meaningless. We demonstrate the limitations of three Python unit-libraries and present a justification and method for checking kind-of-quantity.

Cite

@article{arxiv.1807.07643,
  title  = {Physical-type correctness in scientific Python},
  author = {Marcus Foster and Sean Tregeagle},
  journal= {arXiv preprint arXiv:1807.07643},
  year   = {2018}
}

Comments

6 pages. v2 expanded Abstract only. v3 added reference to/description of/code example for recent units library unyt arXiv:1806.02417; fixed typos

R2 v1 2026-06-23T03:08:02.866Z