From 5edf216165dd6b3233b9c39c57b875c921494874 Mon Sep 17 00:00:00 2001 From: mferrera Date: Fri, 23 Aug 2024 14:23:20 +0200 Subject: [PATCH 1/3] BLD: Build against numpy >= 2.0.0rc1 This unpins numpy<2 and builds the SWIG C library against numpy >= 2.0.0rc1. Versions of numpy major 2 are backward compatible with numpy 1. Hence we should not see issues in environment where numpy<2 may be maintained for years to come, i.e. RMS environments. The numpy SWIG bindings committed in this repository are not out-of-date in a way that would break compatibility. The last update to them in numpy's repository was two years ago from the time of this commit. --- .github/workflows/mypy.yml | 2 +- .github/workflows/publish.yml | 3 --- .github/workflows/test.yml | 16 +--------------- pyproject.toml | 6 +++--- tests/test_grid3d/test_grid_property.py | 7 ++++++- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 7750e59cf..083d041ce 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -16,7 +16,7 @@ jobs: mypy: strategy: matrix: - python-version: ["3.8", "3.11"] + python-version: ["3.9", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bf8d841e6..023b9f462 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,6 @@ jobs: fail-fast: false matrix: python: - - ['3.8', cp38] - ['3.9', cp39] - ['3.10', cp310] - ['3.11', cp311] @@ -26,8 +25,6 @@ jobs: - [macos-13, macosx_x86_64] # macos-13 is the last x86-64 runner - [macos-latest, macosx_arm64] # macos-latest is always arm64 going forward exclude: - - os_arch: [macos-latest, macosx_arm64] - python: ['3.8', cp38] - os_arch: [macos-latest, macosx_arm64] python: ['3.9', cp39] env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5cdb65e58..5afb0f869 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,15 +18,13 @@ jobs: timeout-minutes: 15 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest] include: - os: macos-latest python-version: "3.10" - os: macos-latest python-version: 3.12 - - os: windows-latest - python-version: 3.8 - os: windows-latest python-version: 3.12 @@ -86,18 +84,6 @@ jobs: fail-fast: false matrix: config: - - { - name: "RMS 12.1.4, 13.0.3, 13.1.0, 14.1.1", - os: ubuntu-20.04, - python: 3.8.6, - pip: 23.2.1, - wheel: 0.37.1, - setuptools: 63.4.3, - matplotlib: 3.3.2, - numpy: 1.19.2, - pandas: 1.1.3, - scipy: 1.5.3, - } - { name: "RMS 14.2", os: ubuntu-latest, diff --git a/pyproject.toml b/pyproject.toml index 08f1cc5b2..68d886f06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,8 @@ requires = [ "numpy==1.19.2; python_version == '3.8'", "numpy==1.19.5; python_version == '3.9'", "numpy==1.21.6; python_version == '3.10'", - "numpy==1.23.5; python_version == '3.11'", - "numpy==1.26.2; python_version == '3.12'", + "numpy==1.23.5; python_version <= '3.11.3'", + "numpy==2.0.0; python_version > '3.11.3'", ] build-backend = "scikit_build_core.build" @@ -53,7 +53,7 @@ dependencies = [ "hdf5plugin>=2.3", "joblib", "matplotlib>=3.3", - "numpy<2", + "numpy", "pandas>=1.1", "resfo>=4.0.0", "roffio>=0.0.2", diff --git a/tests/test_grid3d/test_grid_property.py b/tests/test_grid3d/test_grid_property.py index 02d1e1358..a2ff28c66 100644 --- a/tests/test_grid3d/test_grid_property.py +++ b/tests/test_grid3d/test_grid_property.py @@ -116,7 +116,12 @@ def test_assign(): # this shall now broadcast the value 33 to all activecells x.isdiscrete = True x.values = 33 - assert x.dtype == np.int32 + + numpy_version = tuple(map(int, np.__version__.split("."))) + if numpy_version >= (2, 0, 0): + assert x.dtype == np.int64 + else: + assert x.dtype == np.int32 x.isdiscrete = False x.values = 44.0221 From 438a0edfa6b6bb559f2e224546f99e3ad532ce59 Mon Sep 17 00:00:00 2001 From: mferrera Date: Fri, 23 Aug 2024 14:46:39 +0200 Subject: [PATCH 2/3] TYP: Fix Python 3.12 type annotation --- src/xtgeo/grid3d/_ecl_inte_head.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xtgeo/grid3d/_ecl_inte_head.py b/src/xtgeo/grid3d/_ecl_inte_head.py index 1c317b828..71781de3c 100644 --- a/src/xtgeo/grid3d/_ecl_inte_head.py +++ b/src/xtgeo/grid3d/_ecl_inte_head.py @@ -4,6 +4,7 @@ from typing import Any, Literal, cast import numpy as np +import numpy.typing as npt from ._ecl_output_file import Phases, Simulator, TypeOfGrid, UnitSystem @@ -29,7 +30,7 @@ class InteHead: True """ - def __init__(self, values: np.ndarray[np.int_, Any]) -> None: + def __init__(self, values: npt.NDArray[np.int_]) -> None: """Create an InteHead from the corresponding array. Args: From e7335b64d4e2a44af9d5bc56c44c429fbf457d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20C=2E=20Riven=C3=A6s?= Date: Tue, 7 Jan 2025 15:39:15 +0100 Subject: [PATCH 3/3] WIP JRIV --- pyproject.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 68d886f06..b112b09fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,9 @@ requires = [ "scikit-build-core[pyproject]>=0.10", "swig<4.3.0", "numpy==1.19.2; python_version == '3.8'", - "numpy==1.19.5; python_version == '3.9'", - "numpy==1.21.6; python_version == '3.10'", - "numpy==1.23.5; python_version <= '3.11.3'", - "numpy==2.0.0; python_version > '3.11.3'", + "numpy>=2.0.0; python_version > '3.8'", ] + build-backend = "scikit_build_core.build" [tool.scikit-build]