Thanks to visit codestin.com
Credit goes to github.com

Skip to content

quantities 0.16.0 and newer cannot parse 'angstrom' #250

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

Closed
JacksonBurns opened this issue Nov 20, 2024 · 0 comments · Fixed by #251
Closed

quantities 0.16.0 and newer cannot parse 'angstrom' #250

JacksonBurns opened this issue Nov 20, 2024 · 0 comments · Fixed by #251

Comments

@JacksonBurns
Copy link

The changes introduced in this PR: #236

Make it impossible to parse 'angstrom', since the built in function str partially matches 'angstrom' and is therefore in that string, see this code snippet from quantities/registry.py/example that reproduces the issue:

import builtins

string = 'angstrom'

all_builtins = dir(builtins)
# because we have kilobytes, other bytes we have to remove bytes
all_builtins.remove("bytes")
# have to deal with octet as well
all_builtins.remove("oct")
# have to remove min which is short for minute
all_builtins.remove("min")
for builtin in all_builtins:
    if builtin in string:
        raise RuntimeError(f"String parsing error for `{string}`. Enter a string accepted by quantities")

Can in be chnaged to == to avoid partial matches like this?

This is somewhat similar to the inability to parse min mentioned here: #242

@JacksonBurns JacksonBurns changed the title quantities 16.0 and newer cannot parse 'angstrom' quantities 0.16.0 and newer cannot parse 'angstrom' Nov 20, 2024
apdavison added a commit to apdavison/python-quantities that referenced this issue Dec 3, 2024
apdavison added a commit to apdavison/python-quantities that referenced this issue Dec 3, 2024
apdavison added a commit to apdavison/python-quantities that referenced this issue Dec 3, 2024
apdavison added a commit to apdavison/python-quantities that referenced this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant