-
Notifications
You must be signed in to change notification settings - Fork 5
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
Higher-order unit conversion with GWP context #36
Comments
And so our hacking comes back to bites us. I think it's all related to how we define these conversions, we basically have to define composite changes too like here
Option a: Add these energy type conversions too I would go for option a as it is simplest. Option c would be a good alternative. |
I think it's an issue in pint though, the way it does its search for a way between the two units is weird in a context. It basically searches for the entire unit, not just the bit that is actually covered by the context. I don't know how easy or otherwise that is to fix. |
Good detective work. Option a would be the simplest given that there is already functionality to build the unit graph. The downside is that we can't capture all permutations that could be useful and the error message isn't exactly helpful. But adding a few extras shouldn't hurt? Do you see an easy way to detect this situation and provide a better error message/raise a different exception? |
Ye definitely fine until we work out a longer term solution
It's probably possible to do something with base units (pint has some functionality to show the difference) and then if they're both units we've defined say something like 'check compound units' but it would take some fiddling I suspect |
Describe the bug
Unit conversion fails when using a GWP context for units that have higher-order dimensionality. For example, one cannot convert
kg CO2/EJ
tokg CH4/EJ
, butkg CO2/yr
=>kg CH4/yr
works.The above example fails with the following message:
Maybe I'm doing something wrong, but the dimensions match (except for carbon=>CH4 which should be handled by the GWP context).
Failing Test
This test fails with the following exception message:
Expected behavior
Units are able to be converted
System (please complete the following information):
Ubuntu
Python 3.9
commit f97fac6
@znicholls @rgieseke
The text was updated successfully, but these errors were encountered: