From 545296aac4a9524495f0824894c6a72bb8d06a95 Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:00:05 +0000 Subject: [PATCH] ci: bump integration test to 3.9+ & patch `np.Inf` (#2826) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit 06c005f6ceeb88a36e3bb7f6a1337c4f8f8e5645) --- .github/workflows/ci-integrate.yml | 2 +- src/torchmetrics/__init__.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-integrate.yml b/.github/workflows/ci-integrate.yml index f904e0a84b8..11bbe401f83 100644 --- a/.github/workflows/ci-integrate.yml +++ b/.github/workflows/ci-integrate.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-22.04", "macOS-13", "windows-2022"] - python-version: ["3.8", "3.10"] + python-version: ["3.9", "3.11"] requires: ["oldest", "latest"] exclude: - { python-version: "3.11", requires: "oldest" } diff --git a/src/torchmetrics/__init__.py b/src/torchmetrics/__init__.py index 2fa370cb1c9..15f7be3ae90 100644 --- a/src/torchmetrics/__init__.py +++ b/src/torchmetrics/__init__.py @@ -14,6 +14,13 @@ _PACKAGE_ROOT = os.path.dirname(__file__) _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT) +if package_available("numpy"): + # compatibility for AttributeError: `np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead + import numpy + + numpy.Inf = numpy.inf + + if package_available("PIL"): import PIL