v0.5.0 - Affine and Cross-System Conversions
0.5.0 adds affine and cross-system conversions while preserving the package’s strict explicit-conversion model. Conversions now cover offset-based temperature scales, common imperial and US customary units, familiar composite target-unit rendering, and pico-prefixed SI units.
Added
- Affine conversion metadata on unit definitions.
- Explicit Celsius, Fahrenheit, and Kelvin conversions through:
Quantity.to(...)convert(...)
- New
units.imperialnamespace with:- length:
inch,foot,yard,mile - mass:
ounce,pound - temperature:
fahrenheit
- length:
- Display metadata for anonymous composite target units, so explicit conversions can render requested units such as
km·h^-1. - Pico-prefixed SI units:
picometrepicogrampicosecond
Changed
degree_celciusnow converts explicitly to and fromkelvin.- Affine units are rejected from multiplicative arithmetic where offsets would make the result ambiguous.
- Float noise is cleaned up during rendering without changing stored numeric values.
- Package version bumped to
0.5.0.
Examples
from units import convert
from units.imperial import fahrenheit, mile
from units.si import degree_celcius, hour, kelvin, kilometre
print(convert(0 * degree_celcius, kelvin)) # 273.15 K
print(convert(32 * fahrenheit, degree_celcius)) # 0 °C
speed = 60 * mile / hour
print(convert(speed, kilometre / hour)) # 96.56064 km·h^-1