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

Improve the parsing of list of quantities, and allow the parsing of percentage values. #12

Merged
merged 8 commits into from
Jul 5, 2024

Conversation

bramp
Copy link
Contributor

@bramp bramp commented Jul 1, 2024

For example Melting point: 75% -17.5 °C; 80% 4.6 °C; 85% 21 °C. will now return

[Quantity('75%'), Quantity('-17.5 degC')],
[Quantity("80%"), Quantity('4.6 degC')],
[Quantity("85%"), Quantity('21 degC')],

Where previously it returned just Quantity("4.6 degC").

All other examples continue to work the way they did before. But strings such as 10% will also work now.

Fixes #10

In python 3.12 these are now Syntax Errors instead of Deprecation warnings.
@bramp
Copy link
Contributor Author

bramp commented Jul 1, 2024

Oh this change is based on #11 (support Python 3.12), but can be rebased to be independent.

…a unify dash.

The tests previously weren't working correctly. Specifically when doing Quantity('-123') with a unify dash, pint would actually return the Quantity('123'). The test doesn't catch this, as the test is effectively doing Quantity($input) == Quantity($input).

With Python 3.12, the internals of Quantity changed, to explictly reject unify dashes, instead of silently skipping them.
In pint 0.21 ppm was officially added, named ppm, instead of parts_per_million.
…ercentage values.

For example

     'Melting point: 75% -17.5 °C; 80% 4.6 °C; 85% 21 °C.' will now return
        [Quantity('75%'), Quantity('-17.5 degC')],
        [Quantity("80%"), Quantity('4.6 degC')],
        [Quantity("85%"), Quantity('21 degC')],
     Where previously it returned just `Quantity("4.6 degC")`.

All other examples continue to work the way they did before. But strings such as "10%" will also work now.
Copy link
Owner

@dylanwal dylanwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition!

@dylanwal dylanwal merged commit 1bdcb85 into dylanwal:master Jul 5, 2024
0 of 3 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.

unit_parse does not support parsing percentages
2 participants