Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversion from pint to UCUM code #10

Open
dalito opened this issue Jan 19, 2024 · 0 comments · May be fixed by #11
Open

Add conversion from pint to UCUM code #10

dalito opened this issue Jan 19, 2024 · 0 comments · May be fixed by #11

Comments

@dalito
Copy link
Owner

dalito commented Jan 19, 2024

This should be not too difficult to add. Most unclear is how to extend pint best for this kind of conversion.

The idea is to add methods get the corresponding UCUM string from pint quantities and pint units:

>>> q = 5 * ureg("m/kg**3)
>>> q
<Quantity(5, 'kilogram / meter ** 3')>
>>> q.to_ucum()
'kg.m-3'
>>> u = q.units
>>> u
<Unit('kilogram / meter ** 3')>
>>> u.to_ucum()
'kg.m-3'
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 a pull request may close this issue.

1 participant