The shipped radiation_weighting formula cannot be used with the obvious dimensionless literal.
Reproduction
from ucon import Number, parse_unit
from ucon.system import active_kinds
L = active_kinds()
D = Number(quantity=2, unit=parse_unit('Gy'), kind=L.get('absorbed_dose'))
wR = Number(quantity=20, unit=parse_unit('1'), kind=L.get('radiation_weighting_factor'))
KindDimensionMismatch: Kind 'radiation_weighting_factor' has dimension
Dimension(none), but unit 'fraction' has dimension Dimension(ratio).
A Number's kind must refine the dimension of its unit.
Cause
radiation_weighting_factor is declared dimension = "none" (ucon/comprehensive.ucon.toml:5230), but parse_unit('1') resolves to fraction, whose dimension is ratio. The __post_init__ check at ucon/core/_types.py:1631 then refuses the construction.
Constructing a Dimension.none unit by hand works, and the formula itself is correct:
none_unit = Unit(name='one', dimension=Dimension.none)
H = D * Number(quantity=20, unit=none_unit, kind=L.get('radiation_weighting_factor'))
# → 40, kind: dose_equivalent ✓ H = D · w_R per ICRP 103
Why it matters
The formula ships in the default registry, so it is presented as ready to use. A caller reaching for it writes parse_unit('1') — the natural spelling for a dimensionless multiplier — and gets a type error naming two dimensions they did not choose. Getting it right requires knowing that none and ratio are distinct and that no shipped unit carries none.
Possible directions
- Declare the kind as
ratio so it matches the dimensionless unit callers actually have, if that is semantically acceptable.
- Ship a
none-dimensioned unit (or make parse_unit('1') yield one) so there is a spelling that works.
- Or, if the distinction is deliberate, say so in the formula's
notes and give the working incantation — the error message explains what is wrong but not what to write instead.
Found while verifying the formula for #303. Unrelated to that issue's disposition.
The shipped
radiation_weightingformula cannot be used with the obvious dimensionless literal.Reproduction
Cause
radiation_weighting_factoris declareddimension = "none"(ucon/comprehensive.ucon.toml:5230), butparse_unit('1')resolves tofraction, whose dimension isratio. The__post_init__check atucon/core/_types.py:1631then refuses the construction.Constructing a
Dimension.noneunit by hand works, and the formula itself is correct:Why it matters
The formula ships in the default registry, so it is presented as ready to use. A caller reaching for it writes
parse_unit('1')— the natural spelling for a dimensionless multiplier — and gets a type error naming two dimensions they did not choose. Getting it right requires knowing thatnoneandratioare distinct and that no shipped unit carriesnone.Possible directions
ratioso it matches the dimensionless unit callers actually have, if that is semantically acceptable.none-dimensioned unit (or makeparse_unit('1')yield one) so there is a spelling that works.notesand give the working incantation — the error message explains what is wrong but not what to write instead.Found while verifying the formula for #303. Unrelated to that issue's disposition.