Skip to content

v0.7.0

Choose a tag to compare

@DaitTHU DaitTHU released this 19 Oct 03:32

unitx 0.7.0 adds clearer unit spelling policies and richer unit-expression syntax, and shares the SI definitions used by units and physical constants.

Highlights

  • prefixable: PrefixPolicy = True accepts a bool or tuple of registered unit spellings, such as ('arcsec', 'arcsecond'). Only listed spellings accept prefixes. The existing True/False behavior remains available.
  • Use [registered name] inside products, reciprocals, and powers. Standalone hyphenated names and adjacent Unicode integer superscripts such as m² and s⁻¹² are supported.
  • Unit definitions, spelling resolution, and registration validation now share unitx.unitregistry, including the public PrefixPolicy type alias.
  • SI units and constants share coherent base definitions. ly derives from the speed of light and Julian year; eV derives from the elementary charge and volt.
  • The catalog includes are, hectare, Julian year, fixed month interval, light year, unified atomic mass unit, reactive power, and additional common prefixed attributes.
  • mHg is the registered prefixable unit; mmHg uses its milli prefix. The existing pressure conversion scale is preserved, and stacked prefixes are rejected.

Migration

  • Square brackets and integer superscripts are reserved syntax and cannot occur in custom registered spellings. Rename affected definitions before rebuilding stored objects.
  • mmHg has the formal identity of milli-prefixed mHg; rebuild stored units when upgrading. Its conversion scale is unchanged.
  • Registering u introduces ambiguity warnings for ASCII micro spellings such as um. Their meaning is unchanged; use µm, μm, or micrometre to avoid the warning.
  • kt remains a knot alias; tonne remains unprefixable. yr remains 365 days, while a_j is exactly 365.25 days. mo is one twelfth of a Julian year, not a calendar month.

Validation

  • Python 3.12 with the built-in factorization backend: 2528 passed, 2 skipped, including Pyright.
  • Python 3.13 with SymPy: 2529 passed (type checks run separately under Python 3.12).
  • Ruff, README examples, fresh-process imports, and 2685 spelling/expression round trips passed.
  • Wheel/sdist metadata, installed-wheel runtime checks, py.typed packaging, installed README examples, and a strict external Pyright consumer passed.