Skip to content

Parse from_ucum into the registry instance - #80

Merged
dalito merged 1 commit into
dalito:mainfrom
adrianschneider94:from-ucum-uses-the-registry
Nov 5, 2026
Merged

dalito merged 1 commit into
dalito:mainfrom
adrianschneider94:from-ucum-uses-the-registry

Conversation

@adrianschneider94

Copy link
Copy Markdown
Contributor

Fixes #79.

  • PintUcumRegistry builds its transformer with ureg=self, so from_ucum returns quantities of the instance and honours its options (non_int_type, case_sensitive, …).
  • UcumToPintTransformer uses the registry's number type for the implicit 1 of a unary division (/h) and of an annotation in a term ({rbc}/L), so a Decimal registry doesn't mix float and Decimal. A float registry gives the same results as before.
  • Tests: with PintUcumRegistry(non_int_type=Decimal), from_ucum returns quantities of that registry, and mL, /h and {rbc}/L convert to base units as exact Decimals (mL → 0.000001). They fail without the change.

The full suite passes with pint 0.25.3 (3548 passed, 10 skipped). ruff check reports the same six PLC0415 findings in tests/conftest.py as on main.

🤖 Generated with Claude Code

PintUcumRegistry built its transformer without passing itself, so
from_ucum parsed into the application registry and ignored the
instance's options (non_int_type, case_sensitive, ...).

The transformer also computed the implicit 1 of a unary division (/h)
and of an annotation in a term ({rbc}/L) as the int 1, which mixes
float and Decimal in a Decimal registry. It now uses the registry's
number type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dalito

dalito commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR. The change is fine. But I would prefer not to have this "Co-Authored-By: Claude Opus 5.5" nonsense in ucumvert. It is your contribution and CC is just a tool not an author. I merge nevertheless as its not worth to delay the fix for this.

I should probably add an AI Covenant file...

@dalito
dalito merged commit 8ba6729 into dalito:main Nov 5, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PintUcumRegistry.from_ucum parses into the application registry, not the instance (e.g. non_int_type=Decimal is ignored)

2 participants