Skip to content

physipy

physipy lets you manipulate physical quantities in Python — the association of a value (a scalar, a numpy.ndarray, and more) with a physical unit (such as meter or joule). Dimensional consistency is enforced automatically.

from physipy import units, constants

nm = units["nm"]      # nanometer
hp = constants["h"]   # Planck's constant
c  = constants["c"]   # speed of light

E_ph = hp * c / (500 * nm)   # energy of a 500 nm photon
print(E_ph)                  # 3.9728917142978567e-19 kg*m**2/s**2

E_ph.favunit = units["J"]    # choose a display ("favourite") unit
print(E_ph)                  # 3.9728917142978567e-19 J

Where to go next

At a glance

  • Light-weight — two core classes, Dimension and Quantity.
  • numpy-friendly — 150+ functions and ufuncs work transparently on quantities.
  • Lean by default — only numpy is required; scipy, matplotlib and sympy are optional extras.
  • Typed — ships inline type hints (PEP 561).

Source code and issues live on GitHub; releases are on PyPI.