-
Notifications
You must be signed in to change notification settings - Fork 451
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
Allow string parsing of offset units #1349
base: master
Are you sure you want to change the base?
Conversation
This fix will probably not work for compound offset units such as |
Not completely sure what I see in the CI results here (haven't worked with GitHub CI recently). |
Would e.g. |
I believe Generally: As I tried to stipulate in #1350, products involving offset units are generally questionable, as they lack a physical meaning - IHMO they should be completely disallowed. However, this PR simply follows the rules set by pint; it makes the expression parser accept "forming of quantity" involving offset units, and then continues evaluating the expression given in the string according to pint's rules. I think that is the least surprising behaviour. |
e0afe5d
to
528227a
Compare
It seems that #386 is still unsolved. At our company, we have been using a fork of pint for the past two years to get faster access to some fixes that we care for particularly. One of these things is the ability to serialise quantities to json or yaml and back elegantly as a single, human-readable string rather than an ugly @hgrecco, @dalito: What was speaking against merging this two years ago? Obviously, by now, this PR has become stale, but I would be willing to revive it if there is any chance that it would be merged. |
pre-commit run --all-files
with no errorsThe fix implements special handling for implicit multiplications in the string parser when the left operand is not a quantity:
Then, it creates a quantity directly, instead of multiplying the two operands.
For this to work, the
string_preprocessor
had to be modified not to replace implicit multiplications with explicit multiplications.