From 4c25f321e09b05c311b70c5c8fbdc5f021d95d6a Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Fri, 21 Jun 2024 14:24:44 +0100 Subject: [PATCH] support 3.9 (#2019) changed matplotlib test to use a build that has a pypi wheel available for python3.10 changed TypeAlias import for 3.9 compat changed min versions --- .github/workflows/ci.yml | 8 ++++---- CHANGES | 4 ++-- docs/user/log_units.rst | 6 +++--- pint/compat.py | 6 +++++- pint/delegates/formatter/_compound_unit_helpers.py | 3 +-- pyproject.toml | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0797decb5..24f001b43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,18 +7,18 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] numpy: [null, "numpy>=1.23,<2.0.0", "numpy>=2.0.0rc1"] uncertainties: [null, "uncertainties==3.1.6", "uncertainties>=3.1.6,<4.0.0"] extras: [null] include: - python-version: "3.10" # Minimal versions - numpy: "numpy" - extras: matplotlib==2.2.5 + numpy: "numpy>=1.23,<2.0.0" + extras: matplotlib==3.5.3 - python-version: "3.10" numpy: "numpy" uncertainties: "uncertainties" - extras: "sparse xarray netCDF4 dask[complete]==2023.4.0 graphviz babel==2.8 mip>=1.13" + extras: "sparse xarray netCDF4 dask[complete]==2024.5.1 graphviz babel==2.8 mip>=1.13" runs-on: ubuntu-latest env: diff --git a/CHANGES b/CHANGES index 8e59b4803..588e7f5b7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,11 +1,11 @@ Pint Changelog ============== -0.25 (unreleased) +0.24.1 (unreleased) ----------------- - Fix custom formatter needing the registry object. (PR #2011) - +- Support python 3.9 following difficulties installing with NumPy 2. (PR #2019) 0.24 (2024-06-07) ----------------- diff --git a/docs/user/log_units.rst b/docs/user/log_units.rst index 03e007914..096397350 100644 --- a/docs/user/log_units.rst +++ b/docs/user/log_units.rst @@ -111,16 +111,16 @@ will not work: .. doctest:: >>> -161.0 * ureg('dBm/Hz') == (-161.0 * ureg.dBm / ureg.Hz) - False + np.False_ But this will: .. doctest:: >>> ureg('-161.0 dBm/Hz') == (-161.0 * ureg.dBm / ureg.Hz) - True + np.True_ >>> Q_(-161.0, 'dBm') / ureg.Hz == (-161.0 * ureg.dBm / ureg.Hz) - True + np.True_ To begin using this feature while avoiding problems, define logarithmic units as single-unit quantities and convert them to their base units as quickly as diff --git a/pint/compat.py b/pint/compat.py index 277662410..32ad04afb 100644 --- a/pint/compat.py +++ b/pint/compat.py @@ -19,9 +19,13 @@ from typing import ( Any, NoReturn, - TypeAlias, # noqa ) +if sys.version_info >= (3, 10): + from typing import TypeAlias # noqa +else: + from typing_extensions import TypeAlias # noqa + if sys.version_info >= (3, 11): from typing import Self # noqa else: diff --git a/pint/delegates/formatter/_compound_unit_helpers.py b/pint/delegates/formatter/_compound_unit_helpers.py index 89bda87a2..7631a94ef 100644 --- a/pint/delegates/formatter/_compound_unit_helpers.py +++ b/pint/delegates/formatter/_compound_unit_helpers.py @@ -20,12 +20,11 @@ TYPE_CHECKING, Any, Literal, - TypeAlias, TypedDict, TypeVar, ) -from ...compat import babel_parse +from ...compat import TypeAlias, babel_parse from ...util import UnitsContainer T = TypeVar("T") diff --git a/pyproject.toml b/pyproject.toml index a376bd6a4..9f29f8f92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,11 +22,12 @@ classifiers = [ "Programming Language :: Python", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Libraries", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] -requires-python = ">=3.10" +requires-python = ">=3.9" dynamic = ["version", "dependencies"] [tool.setuptools.package-data]