From 9fe0d59557a1ff5ffb4041d4ef8a572073ad5941 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 13 Oct 2026 22:49:40 +0200 Subject: [PATCH 1/2] Fix type checking with NumPy 2.5 NumPy 2.5 defines `numpy.typing.NDArray` with a PEP 695 `type` statement, which cannot be used as a base class, so `mypy` fails on `class Quantity(npt.NDArray)`. The stub now subclasses `np.ndarray[Any, np.dtype[Any]]` directly, which works with all supported NumPy versions. --- quantities/quantity.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quantities/quantity.pyi b/quantities/quantity.pyi index 2d5db95..3e800a3 100644 --- a/quantities/quantity.pyi +++ b/quantities/quantity.pyi @@ -1,5 +1,6 @@ from typing import Any, Optional +import numpy as np import numpy.typing as npt from quantities.dimensionality import Dimensionality @@ -21,7 +22,7 @@ def scale_other_units(f: Any) -> None: ... -class Quantity(npt.NDArray): +class Quantity(np.ndarray[Any, np.dtype[Any]]): def __new__(cls, data: QuantityData, units: DimensionalityDescriptor = ..., dtype: Optional[object] = ..., copy: bool = ...) -> Quantity: From b352cbdab218a2de16ccb0041562fdc1751c5ab4 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 13 Oct 2026 22:49:40 +0200 Subject: [PATCH 2/2] Update supported Python and NumPy versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following the policy of NEP 29 plus one year, drop support for Python 3.10 and NumPy 1.24–1.26, and add CI testing for Python 3.15 and NumPy 2.5. CI now installs the latest patch release of each NumPy minor version rather than the .0 release, so that combinations with wheels available in a later patch release use them instead of compiling NumPy from source. --- .github/workflows/test.yml | 74 ++++++-------------------------------- CHANGES.txt | 2 ++ doc/user/installation.rst | 4 +-- pyproject.toml | 6 ++-- 4 files changed, 17 insertions(+), 69 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b99daa4..a809cff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,41 +12,14 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ] - numpy-version: [ "1.24", "1.25", "1.26", "2.0", "2.1", "2.2", "2.3", "2.4" ] + python-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ] + numpy-version: [ "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" ] exclude: - - python-version: "3.10" - numpy-version: "2.3" - os: ubuntu-latest - - python-version: "3.10" - numpy-version: "2.4" - os: ubuntu-latest - python-version: "3.11" numpy-version: "2.4" os: ubuntu-latest - - python-version: "3.12" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.12" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.26" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.26" + - python-version: "3.11" + numpy-version: "2.5" os: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -76,7 +49,7 @@ jobs: python -m pip install -U setuptools python -m pip install -U wheel python -m pip install -U pytest - python -m pip install "numpy==${{ matrix.numpy-version }}" + python -m pip install "numpy==${{ matrix.numpy-version }}.*" - name: Install run: | @@ -93,41 +66,14 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ] - numpy-version: [ "1.24", "1.25", "1.26", "2.0", "2.1", "2.2", "2.3", "2.4" ] + python-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ] + numpy-version: [ "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" ] exclude: - - python-version: "3.10" - numpy-version: "2.3" - os: ubuntu-latest - - python-version: "3.10" - numpy-version: "2.4" - os: ubuntu-latest - python-version: "3.11" numpy-version: "2.4" os: ubuntu-latest - - python-version: "3.12" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.12" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.13" - numpy-version: "1.26" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.24" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.25" - os: ubuntu-latest - - python-version: "3.14" - numpy-version: "1.26" + - python-version: "3.11" + numpy-version: "2.5" os: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -156,7 +102,7 @@ jobs: python -m pip install -U pip python -m pip install -U setuptools python -m pip install -U wheel - python -m pip install "numpy==${{ matrix.numpy-version }}" + python -m pip install "numpy==${{ matrix.numpy-version }}.*" python -m pip install -U pytest python -m pip install -U mypy diff --git a/CHANGES.txt b/CHANGES.txt index 73e05ed..745e308 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,8 @@ Unreleased - Correct the pond force unit to 0.00980665 N (one gram-force); it was previously 1000 times too large (`#44 `_). +- Fix type checking with NumPy 2.5 +- Add CI testing for Python 3.15 and NumPy 2.5, drop support for Python 3.10 and for NumPy 1.x (following NEP 29 plus one year) ------ 0.16.4 diff --git a/doc/user/installation.rst b/doc/user/installation.rst index f3c40c9..5d6423d 100644 --- a/doc/user/installation.rst +++ b/doc/user/installation.rst @@ -8,8 +8,8 @@ Prerequisites Quantities has a few dependencies: -* Python_ (>=3.8) -* NumPy_ (>=1.19) +* Python_ (>=3.11) +* NumPy_ (>=2.0) (bearing in mind that not all combinations of Python and NumPy versions necessarily work). diff --git a/pyproject.toml b/pyproject.toml index 4fe21e6..96e5779 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "quantities" description = "Support for physical quantities with units, based on numpy" readme = "README.rst" -requires-python = ">=3.10" +requires-python = ">=3.11" license-files = ["doc/user/license.rst"] authors = [ {name = "Darren Dale", email = "dsdale24@gmail.com"} @@ -24,7 +24,7 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - "numpy>=1.24" + "numpy>=2.0" ] dynamic = ["version"] @@ -58,7 +58,7 @@ write_to = "quantities/_version.py" [tool.ruff] line-length = 120 -target-version = "py310" +target-version = "py311" [tool.ruff.lint] # pycodestyle errors and warnings, pyflakes, isort.