Skip to content

Conversation

@kroenlein
Copy link
Collaborator

@kroenlein kroenlein commented Aug 15, 2024

GEMD Python PR

Description

This PR updates gemd-python to be compatible with latest (0.24.3) pint.

It marks both 0.22 and 0.23 as incompatible because these two libraries are incompatible with numpy >= 2 but are not annotated as such in their setup.py. A Python 3.8 installation is incompatible with numpy >= 2 and a Python 3.9 installation is compatible with Pint >= 0.24, so this configuration protects us from the unfortunate configuration.

It also incorporates the minor updates to the Pint default units definition file 0.23 -> 0.24.3.

https://citrine.atlassian.net/browse/SPT-1493

PR Type:

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Maintenance (non-breaking change to assist developers)

Adherence to team decisions

  • I have added tests for 100% coverage
  • I have written Numpy-style docstrings for every method and class.
  • I have communicated the downstream consequences of the PR to others.
  • I have bumped the version in __version__.py

@kroenlein kroenlein requested a review from anoto-moniz August 15, 2024 03:15
Comment on lines +308 to +325
try: # Informal route changed in 0.22
from pint.formatting import _FORMATTERS
formatter = _FORMATTERS["D"]
except ImportError: # pragma: no cover
from pint import Unit
formatter_obj = registry.formatter._formatters["D"]

def _surrogate_formatter(unit, registry, **options):
try:
parsed = Unit(unit)
return formatter_obj.format_unit(parsed)
except ValueError:
parsed = Unit(unit)
return formatter_obj.format_quantity(unit)

formatter = _surrogate_formatter

return formatter(unit, registry, **options)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is all to support a function marked for removal in 3.0

@kroenlein kroenlein requested a review from jspeerless August 15, 2024 03:21
@jspeerless
Copy link

LGTM!

@kroenlein kroenlein merged commit f3cd227 into main Aug 15, 2024
@kroenlein kroenlein deleted the maintain/pint-0-24-compatability branch August 15, 2024 14:48
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.

3 participants