Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: Build against numpy >= 2.0.0rc1 #1233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
fail-fast: false
matrix:
python:
- ['3.8', cp38]
- ['3.9', cp39]
- ['3.10', cp310]
- ['3.11', cp311]
Expand All @@ -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:
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -82,18 +80,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,
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ requires = [
"pybind11",
"scikit-build-core[pyproject]>=0.10",
"swig",
"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'",
Comment on lines -6 to -10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think this should be replaced without proper testing. The reason is that numpy version for RMS is pinned, and to avoid ABI version issues we should compile on the oldest version of numpy that is supported by a given python version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that we will need to do some thorough testing. A few good indicators so far:

"numpy>=2.0.0rc1",
]
build-backend = "scikit_build_core.build"

Expand Down Expand Up @@ -53,7 +49,7 @@ dependencies = [
"hdf5plugin>=2.3",
"joblib",
"matplotlib>=3.3",
"numpy<2",
"numpy",
"pandas>=1.1",
"resfo>=4.0.0",
"roffio>=0.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/xtgeo/grid3d/_ecl_inte_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_grid3d/test_grid_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +121 to +124
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should probably take another look into this and if there are implications for file sizes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this indicate some problems with backward compatibility?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to test this more


x.isdiscrete = False
x.values = 44.0221
Expand Down