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

Update for Pint 0.20 API breaks #296

Closed
wants to merge 4 commits into from

Conversation

mattwthompson
Copy link
Contributor

@mattwthompson mattwthompson commented Oct 28, 2022

Description

This PR attempts to update QCElemental to work with the newest version of Pint. Version 0.20.0 moved around a ton of stuff internally, although the only breakage here was the disappearance of an easily accessible Quantity class. Somewhat confusingly type(Quantity) returns something that does not obviously exist, but importing directly from the top-level namespace does work.

>>> import pint
>>> ureg = pint.UnitRegistry()
>>> type(ureg.Quantity("1 angstrom"))
<class 'pint.util.Quantity'>
>>> from pint.util import Quantity
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Quantity' from 'pint.util' (/Users/mattthompson/mambaforge/envs/test/lib/python3.11/site-packages/pint/util.py)
>>> from pint import Quantity
>>> isinstance(ureg.Quantity("1 angstrom"), Quantity)
True

Prior to seeing a similar attempt from @loriab, I had this to say, which is not quite correct:

I believe this comes from the code around here - in any case one cannot simply import any sort of Quantity as it is no longer a standalone class but something that dangles off of the registry. Fortunately the change here appears to be simple - the internals were not reached into too deeply and the change to one bit of input sanitization didn't need information it didn't already have in scope.~~

Changelog description

Update for compatibility with Pint 0.20.

Status

  • Code base linted - I'd be happy to move this to use https://pre-commit.ci/ so users never need to lint themselves
  • Ready to go

@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

Merging #296 (e323061) into master (2956421) will decrease coverage by 0.17%.
The diff coverage is 71.42%.

Additional details and impacted files

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 this pull request may close these issues.

None yet

1 participant