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

Skip to content

quantities 0.16.0 and newer cannot parse 'angstrom' #250

Closed
@JacksonBurns

Description

@JacksonBurns

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions