Skip to content

no liter, but litter, works #255

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
Hjorthmedh opened this issue Apr 11, 2025 · 2 comments
Closed

no liter, but litter, works #255

Hjorthmedh opened this issue Apr 11, 2025 · 2 comments

Comments

@Hjorthmedh
Copy link

Hjorthmedh commented Apr 11, 2025

import quantities as pq
pq.__version__
aa = pq.UnitQuantity("liter", pq.L, "liter")
pq.CompoundUnit("1/liter")

In current version 0.16.1 this fails:

>>> import quantities as pq
>>> pq.__version__
'0.16.1'
>>> aa = pq.UnitQuantity("liter", pq.L, "liter")
>>> pq.CompoundUnit("1/liter")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hjorth/HBP/Snudda/snudda_env/lib/python3.11/site-packages/quantities/unitquantity.py", line 376, in __new__
    return UnitQuantity.__new__(cls, name, unit_registry[name])
                                           ~~~~~~~~~~~~~^^^^^^
  File "/home/hjorth/HBP/Snudda/snudda_env/lib/python3.11/site-packages/quantities/registry.py", line 73, in __getitem__
    return self.__registry[label]
           ~~~~~~~~~~~~~~~^^^^^^^
  File "/home/hjorth/HBP/Snudda/snudda_env/lib/python3.11/site-packages/quantities/registry.py", line 30, in __getitem__
    raise RuntimeError(f"String parsing error for `{string}`. Enter a string accepted by quantities")
RuntimeError: String parsing error for `1/liter`. Enter a string accepted by quantities

In 0.14.1 this worked...

Type "help", "copyright", "credits" or "license" for more information.
>>> import quantities as pq
>>> pq.__version__
'0.14.1'
>>> aa = pq.UnitQuantity("liter", pq.L, "liter")
>>> pq.CompoundUnit("1/liter")
1 (1/liter)
>>> 

To make it even more confusing, if we call liter "litter" (double t) instead... it works in the latest version

>>> import quantities as pq
>>> pq.__version__
'0.16.1'
>>> aa = pq.UnitQuantity("liter", pq.L, "litter")
>>> pq.CompoundUnit("1/litter")
1 (1/litter)
>>> 
@apdavison
Copy link
Contributor

This is fixed in the master branch (in #251). I'll make a release.

@apdavison
Copy link
Contributor

Fixed in v0.16.2

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