All notable changes to this project will be documented in this file.
0.5.0 adds affine and cross-system conversions. The release supports explicit
temperature conversions with offsets, introduces a small units.imperial
namespace, and preserves familiar composite target-unit rendering for explicit
conversions such as mile / hour -> kilometre / hour.
- Affine conversion metadata on unit definitions.
- Explicit Celsius, Fahrenheit, and Kelvin conversions through
Quantity.to(...)andconvert(...). units.imperialwith:- length:
inch,foot,yard,mile - mass:
ounce,pound - temperature:
fahrenheit
- length:
- Display labels for anonymous composite target units, so explicit conversions
can render in requested units such as
km·h^-1.
degree_celciusnow converts explicitly to and fromkelvin.- Affine units are rejected from multiplicative arithmetic where offsets would make the result ambiguous.
- Near-integer and near-decimal float noise is cleaned up during rendering without changing stored numeric values.
- Bumped the package version to
0.5.0.
- Addition, subtraction, and modulo still require identical units.
- Deprecated compatibility helpers remain available with
DeprecationWarning. Unit is Quantityremains true until the planned1.0.0breaking release.
0.4.0 introduces the first Phase 10 conversion foundations. The release adds
explicit scale-only conversions, common SI-prefixed units, and small extractor
helpers while preserving the strict unit-compatibility rules for arithmetic.
Quantity.to(target_unit)for explicit same-dimension multiplicative conversions.convert(quantity, target_unit)as a helper equivalent toquantity.to(target_unit).- Extractor helpers:
value(quantity)unit(quantity)multiplier(quantity_or_unit)
- Common prefixed and scaled units:
- length:
kilometre,centimetre,millimetre,micrometre,nanometre,picometre - mass:
gram,milligram,microgram,picogram,tonne - time:
minute,hour,millisecond,microsecond,nanosecond,picosecond - electrical and power units:
milliampere,kiloampere,millivolt,kilovolt,milliwatt,kilowatt,megawatt
- length:
- Multiplication, division, and powers now account for unit conversion factors so scaled-unit arithmetic produces canonical base magnitudes.
- Composite scaled-unit arithmetic renders in canonical SI dimensions to avoid silently displaying scaled values as base units.
- Addition, subtraction, and modulo still require identical units.
- Affine conversions such as
degree_celcius <-> kelvinremain out of scope until the next conversion phase. - Deprecated compatibility helpers from
0.3.0remain available withDeprecationWarning.
0.3.0 implements the compatibility deprecation policy for the modern API
transition. Preferred code should use Quantity, scalar-by-unit construction,
and the *_quantity conversion helpers.
- Bumped the package version to
0.3.0. Unitremains a deprecated compatibility alias forQuantityand is scheduled for removal in1.0.0.- Legacy conversion helpers
int_unit,float_unit,long_unit,complex_unit, andlong_quantitynow emitDeprecationWarningwhen called.
- Deprecated compatibility paths remain available in this release.
- Deprecated compatibility paths are scheduled for removal in
1.0.0. Unitremains a true alias soUnit is Quantityandisinstance(value, Unit)keep working until the breaking release.- Preferred APIs do not emit deprecation warnings.
0.2.0 is the first release in the modernized API line.
This release keeps legacy code working while introducing a clearer and more ergonomic public API, a stronger internal architecture, and a modern Python-only packaging and test workflow.
The preferred API is now:
from units import Quantity
from units.si import metre, second, newton
distance = 10 * metre
time = 2 * second
speed = distance / time
force = 5 * newtonThe explicit constructor remains fully supported:
distance = Quantity(10, metre)Legacy compatibility is still preserved in this release:
import units as u
distance = u.Unit(10, u.metre)Quantityas the preferred quantity typeunits.sias the canonical import location for SI and derived units- scalar-by-unit construction, such as
3 * metre - exponent support for units and quantities, such as
5 * metre ** 3 - immutable
DimensionandDimensionSystemmodels - registry-backed canonicalization for unambiguous SI derived units
- support for custom unit systems through
CustomUnitBase - GitHub Actions CI and publishing workflows
pyproject.tomlpackaging metadatapytest-based unit tests and integration tests- layered source structure under
src/api,src/core,src/models, andsrc/utils - contributor guidance and an explicit project plan
- the package is now Python 3-only
- the preferred construction style is now scalar-by-unit multiplication instead of always calling
Quantity(...) - the runtime package has been refactored into a layered architecture while preserving the
unitsfacade - documentation is now centered on
README.mdwith real-world engineering examples - test and build workflows now reflect the
srclayout and modern Python packaging
- explicit typed validation replaced
assert-based validation - fragile arithmetic paths and unsupported operand handling were corrected
- reverse arithmetic and dimensionless handling were tightened
- custom unit systems were restored after the dimensional refactor and kept separate from SI canonicalization
Unitremains available as a compatibility alias forQuantity- top-level unit exports remain available during the transition
- legacy helper names such as
long_unitandlong_quantitystill exist for compatibility - deprecation warnings are not yet emitted in this release
As of 0.2.0, the project has the following characteristics:
- public facade in
src/units - layered implementation in
src/api,src/core,src/models, andsrc/utils - intentionally empty
src/servicesandsrc/adapterspackages reserved for future growth - Python
3.10+support pytestunit and integration coverage- current verified total coverage of
92% - preferred API based on
3 * metrestyle quantity construction - explicit constructor support retained through
Quantity(value, unit) - legacy API still available for migration
- implement compatibility deprecation policy
- add low-noise warnings for legacy aliases
- define removal timing for legacy paths in a future breaking release