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 check for delta unit to convert #1905

Merged
merged 2 commits into from
May 12, 2024

Conversation

dalito
Copy link
Contributor

@dalito dalito commented Dec 19, 2023

This fixes an oversight in offset unit handling. Offset units have a "delta" counterpart. Converting between offset unit and its delta counterpart is not possible. This was not checked until now resulting in e.g.

>>> import pint
>>> ureg = pint.UnitRegistry()
>>> ureg.Quantity(10, ureg.delta_degC).to("degC")
<Quantity(-263.15, 'degree_Celsius')>

With the PR a DimensionalityError is raised:

>>> ureg.Quantity(10, ureg.delta_degC).to("degC")
...
pint.errors.DimensionalityError: Cannot convert from 'delta_degree_Celsius' to 'degree_Celsius'

Closes #1906

Copy link

codspeed-hq bot commented Dec 19, 2023

CodSpeed Performance Report

Merging #1905 will not alter performance

Comparing dalito:issue1904-delta-bug (991b259) with master (5206fac)

Summary

✅ 437 untouched benchmarks

@dalito dalito marked this pull request as draft December 19, 2023 14:39
@dalito dalito marked this pull request as ready for review December 19, 2023 15:24
@andrewgsavage andrewgsavage merged commit 9a93a68 into hgrecco:master May 12, 2024
42 checks passed
@dalito dalito deleted the issue1904-delta-bug branch May 14, 2024 20:15
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.

pint is converting delta_degree_Celsius to degree_Fahrenheit
2 participants