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

"Derived dimensions cannot have aliases." if pint is updated #9

Closed
bramp opened this issue Jun 30, 2024 · 0 comments · Fixed by #11
Closed

"Derived dimensions cannot have aliases." if pint is updated #9

bramp opened this issue Jun 30, 2024 · 0 comments · Fixed by #11

Comments

@bramp
Copy link
Contributor

bramp commented Jun 30, 2024

tl;dr: Two problems, firstly, unit_parse doesn't work with the latest python + numpy, due to a issue in pint. If I upgrade pint, then unit_parse fails due to outdated support_files.

Very simple program:

import unit_parse

print(unit_parse.parser("1.5 kg"))

fails with:

  File ".venv/lib/python3.12/site-packages/numpy/__init__.py", line 410, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'cumproduct'. Did you mean: 'cumprod'?

which seems to be because of hgrecco/pint#1974, python 3 + numpy 2 + pint don't play nicely. They fixed it in pint 0.24.1, so pip install pint=0.24.1

now fails with:

pint.delegates.txt_defparser.common.DefinitionSyntaxError: Derived dimensions cannot have aliases.
    231,0-231,40 [velocity] = [length] / [time] = [speed]
    .venv/lib/python3.12/site-packages/unit_parse/support_files/constants_en.txt

It seems the support_files/constants_en.txt and support_files/default_en.txt are not the same as the ones that now come with pint. If I update them, everything now works correctly.

Is there any reason unit_parse bundles these files? and doesn't just create a default pint registry? Happy to send a pull request to fix this by either updating the bundled files, or changing to use a default pint setup.

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.

1 participant