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

AttributeError when evaluating "%" #1274

Closed
gerritholl opened this issue Mar 24, 2021 · 1 comment
Closed

AttributeError when evaluating "%" #1274

gerritholl opened this issue Mar 24, 2021 · 1 comment

Comments

@gerritholl
Copy link
Contributor

gerritholl commented Mar 24, 2021

Describe the bug

When parsing the expression % using UnitRegistry.parse_expression, pint throws an AttributeError.

To reproduce

import pint
ureg = pint.UnitRegistry()
ureg.parse_expression("%")

Expected behaviour

I'm not sure what to expect. Maybe 0.01? ureg.parse_expression("1%") gives 1, but I'm not sure if that is accurate.

Actual results

Traceback (most recent call last):
  File "/home/gholl/checkouts/protocode/mwe/pint-ureg.py", line 3, in <module>
    ureg.parse_expression("%")
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/pint/registry.py", line 1263, in parse_expression
    return build_eval_tree(gen).evaluate(
AttributeError: 'NoneType' object has no attribute 'evaluate'

Environment info

The latest pint master (Pint-0.18.dev3+g26e3a8d).

@hgrecco
Copy link
Owner

hgrecco commented Mar 29, 2021

See #429 for the reason why this is not possible and reference therein for fixes.

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

No branches or pull requests

2 participants