Skip to content

Quantities cannot parse "kN" #252

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
apalazzi opened this issue Feb 4, 2025 · 1 comment · Fixed by #253
Closed

Quantities cannot parse "kN" #252

apalazzi opened this issue Feb 4, 2025 · 1 comment · Fixed by #253

Comments

@apalazzi
Copy link

apalazzi commented Feb 4, 2025

As per title, current quantities cannot parse kN:

>>> q.Quantity(1, "km")
array(1) * km
>>> a=q.Quantity(1, "N")
>>> a
array(1) * N
>>> a=q.Quantity(1, "kN")
Traceback (most recent call last):
  File "/home/andrea_palazzi/funimatic-venv/lib/python3.13/site-packages/quantities/registry.py", line 33, in __getitem__
    return eval(string, self.__context)
  File "<string>", line 1, in <module>
NameError: name 'kN' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<python-input-10>", line 1, in <module>
    a=q.Quantity(1, "kN")
  File "/home/andrea_palazzi/funimatic-venv/lib/python3.13/site-packages/quantities/quantity.py", line 131, in __new__
    ret._dimensionality.update(validate_dimensionality(units))
                               ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/andrea_palazzi/funimatic-venv/lib/python3.13/site-packages/quantities/quantity.py", line 34, in validate_dimensionality
    return unit_registry[value].dimensionality
           ~~~~~~~~~~~~~^^^^^^^
  File "/home/andrea_palazzi/funimatic-venv/lib/python3.13/site-packages/quantities/registry.py", line 73, in __getitem__
    return self.__registry[label]
           ~~~~~~~~~~~~~~~^^^^^^^
  File "/home/andrea_palazzi/funimatic-venv/lib/python3.13/site-packages/quantities/registry.py", line 36, in __getitem__
    raise LookupError(
        'Unable to parse units: "%s"'%string
    )
LookupError: Unable to parse units: "kN"
apdavison added a commit to apdavison/python-quantities that referenced this issue Feb 5, 2025
@apdavison apdavison linked a pull request Feb 5, 2025 that will close this issue
@apdavison
Copy link
Contributor

Thanks for the report, we'll add this.

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 a pull request may close this issue.

2 participants