When formatting standalone units with ^ in the spec, format_unit() currently prints ratio form (1/s) instead of negative-power form (s⁻¹), while format_quantity() already behaves correctly.
Example:
ureg.Unit("second")**-1 with "{:~^P}" should print s⁻¹
- currently returns
1/s
This appears to be because FullFormatter.format_unit() does not pass as_ratio=False when ^ is present, unlike format_quantity().
A fix would be to update pint/delegates/formatter/full.py so format_unit() mirrors the ^ handling in format_quantity().
When formatting standalone units with
^in the spec,format_unit()currently prints ratio form (1/s) instead of negative-power form (s⁻¹), whileformat_quantity()already behaves correctly.Example:
ureg.Unit("second")**-1with"{:~^P}"should prints⁻¹1/sThis appears to be because
FullFormatter.format_unit()does not passas_ratio=Falsewhen^is present, unlikeformat_quantity().A fix would be to update
pint/delegates/formatter/full.pysoformat_unit()mirrors the^handling informat_quantity().