From 4831ff56cf90020b8860d10ff7ecc0fa26a22a32 Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Tue, 18 Jun 2024 15:45:28 -0400 Subject: [PATCH 1/8] refactor(dependencies): support numpy 2 --- autotest/test_export.py | 4 ++-- etc/environment.yml | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autotest/test_export.py b/autotest/test_export.py index df550590ba..4d9b9f3794 100644 --- a/autotest/test_export.py +++ b/autotest/test_export.py @@ -410,7 +410,7 @@ def test_export_shapefile_polygon_closed(function_tmpdir): @excludes_platform("Windows") -@requires_pkg("rasterio", "shapefile", "scipy") +@requires_pkg("rasterio", "pyshp", "scipy", name_map={"pyshp": "shapefile"}) def test_export_array(function_tmpdir, example_data_path): import rasterio from scipy.ndimage import rotate @@ -1992,7 +1992,7 @@ def test_vtk_export_disu2_grid(function_tmpdir, example_data_path): @pytest.mark.mf6 @requires_exe("mf6", "gridgen") -@requires_pkg("vtk", "shapefile", "shapely") +@requires_pkg("vtk", "pyshp", "shapely", name_map={"pyshp": "shapefile"}) def test_vtk_export_disu_model(function_tmpdir): from vtkmodules.util.numpy_support import vtk_to_numpy diff --git a/etc/environment.yml b/etc/environment.yml index fdd7cb1dc4..ce04395dff 100644 --- a/etc/environment.yml +++ b/etc/environment.yml @@ -6,7 +6,7 @@ dependencies: # required - python>=3.8 - - numpy>=1.20.3,<2.0.0 + - numpy>=1.20.3,<3.0.0 - matplotlib>=1.4.0 - pandas>=2.0.0 diff --git a/pyproject.toml b/pyproject.toml index 98509cb2c2..a784912f62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "numpy >=1.20.3,<2.0.0", + "numpy >=1.20.3,<3.0.0", "matplotlib >=1.4.0", "pandas >=2.0.0" ] From 07b99140be4154ffedc6053e01bdb7dd618bf970 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 18 Jun 2024 16:17:47 -0400 Subject: [PATCH 2/8] force >= 2 to check tests pass --- etc/environment.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/environment.yml b/etc/environment.yml index ce04395dff..ff3e061e75 100644 --- a/etc/environment.yml +++ b/etc/environment.yml @@ -6,7 +6,7 @@ dependencies: # required - python>=3.8 - - numpy>=1.20.3,<3.0.0 + - numpy>=2.0.0 - matplotlib>=1.4.0 - pandas>=2.0.0 diff --git a/pyproject.toml b/pyproject.toml index a784912f62..08774c3ac5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "numpy >=1.20.3,<3.0.0", + "numpy >=2.0.0", "matplotlib >=1.4.0", "pandas >=2.0.0" ] From f6b3a362b4fbf7d9b7692dbba68ee4d97d901ecd Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 18 Jun 2024 16:26:47 -0400 Subject: [PATCH 3/8] temp remove py3.8 jobs --- .github/workflows/benchmark.yml | 6 +----- .github/workflows/commit.yml | 12 ++++-------- .github/workflows/examples.yml | 6 +----- .github/workflows/optional.yml | 2 +- .github/workflows/release.yml | 4 ++-- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 12fd54a1f9..d6f5f94dce 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -12,11 +12,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] - exclude: - # avoid shutil.copytree infinite recursion bug - # https://github.com/python/cpython/pull/17098 - - python-version: '3.8.0' + python-version: [ 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 0b51dfa910..c3635db88a 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 cache: 'pip' cache-dependency-path: pyproject.toml @@ -55,7 +55,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 cache: 'pip' cache-dependency-path: pyproject.toml @@ -84,7 +84,7 @@ jobs: shell: bash timeout-minutes: 10 env: - PYTHON_VERSION: 3.8 + PYTHON_VERSION: 3.9 steps: - name: Checkout repo @@ -133,11 +133,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] - exclude: - # avoid shutil.copytree infinite recursion bug - # https://github.com/python/cpython/pull/17098 - - python-version: '3.8.0' + python-version: [ 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index d021a66a53..2407f4e4dc 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -12,11 +12,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] - exclude: - # avoid shutil.copytree infinite recursion bug - # https://github.com/python/cpython/pull/17098 - - python-version: '3.8.0' + python-version: [ 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/optional.yml b/.github/workflows/optional.yml index a84940cd9e..c1962380af 100644 --- a/.github/workflows/optional.yml +++ b/.github/workflows/optional.yml @@ -14,7 +14,7 @@ jobs: shell: bash timeout-minutes: 10 env: - PYTHON_VERSION: 3.8 + PYTHON_VERSION: 3.9 strategy: fail-fast: false matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57c19dadd6..92c65dee94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 cache: 'pip' cache-dependency-path: pyproject.toml @@ -211,7 +211,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 cache: 'pip' cache-dependency-path: pyproject.toml From 87f137572d950cf8b07a1c6241f1d20513cc027b Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 18 Jun 2024 16:32:17 -0400 Subject: [PATCH 4/8] fix environment.yml --- etc/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/environment.yml b/etc/environment.yml index ff3e061e75..873b23c634 100644 --- a/etc/environment.yml +++ b/etc/environment.yml @@ -6,7 +6,6 @@ dependencies: # required - python>=3.8 - - numpy>=2.0.0 - matplotlib>=1.4.0 - pandas>=2.0.0 @@ -22,6 +21,7 @@ dependencies: - jupyter_client>=8.4.0 - jupytext - pip: + - numpy>=2.0.0 - git+https://github.com/MODFLOW-USGS/modflow-devtools.git - pytest!=8.1.0 - pytest-benchmark From 2e69b5feffc8337434f1567ac17ec4fe3ad72c51 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 18 Jun 2024 23:12:54 -0400 Subject: [PATCH 5/8] test against fixed mf6 branch --- .github/workflows/mf6.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mf6.yml b/.github/workflows/mf6.yml index 72011cdfc4..32ed85c17c 100644 --- a/.github/workflows/mf6.yml +++ b/.github/workflows/mf6.yml @@ -49,7 +49,8 @@ jobs: - name: Checkout MODFLOW 6 uses: actions/checkout@v4 with: - repository: MODFLOW-USGS/modflow6 + repository: wpbonelli/modflow6 + ref: numpy2-fixes path: modflow6 - name: Build and install MF6 From ae6a7244d9ea2738229224cb448086baec7c0176 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 18 Jun 2024 23:18:32 -0400 Subject: [PATCH 6/8] remove deprecated itemset usage --- flopy/mf6/data/mfdatastorage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flopy/mf6/data/mfdatastorage.py b/flopy/mf6/data/mfdatastorage.py index 8a57413538..7f66574c55 100644 --- a/flopy/mf6/data/mfdatastorage.py +++ b/flopy/mf6/data/mfdatastorage.py @@ -2535,7 +2535,7 @@ def _fill_dimensions(self, data_iter, dimensions): data_array = np.ndarray(shape=dimensions, dtype=np_dtype) # fill array for index in ArrayIndexIter(dimensions): - data_array.itemset(index, next(data_iter)) + data_array[index] = next(data_iter) return data_array elif self.data_structure_type == DataStructureType.scalar: return next(data_iter) From c7da44cf729ba37165fe1202d50bd824aff5a909 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Wed, 19 Jun 2024 00:05:50 -0400 Subject: [PATCH 7/8] restore py3.8 to job matrices (keep some of the other bumps 3.8 -> 3.9) --- .github/workflows/benchmark.yml | 2 +- .github/workflows/commit.yml | 2 +- .github/workflows/examples.yml | 2 +- .github/workflows/mf6.yml | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d6f5f94dce..79ba1028d9 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.9, "3.10", "3.11", "3.12" ] + python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index c3635db88a..23c4cc5d69 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -133,7 +133,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.9, "3.10", "3.11", "3.12" ] + python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 2407f4e4dc..2b78ec044d 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.9, "3.10", "3.11", "3.12" ] + python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] defaults: run: shell: bash -l {0} diff --git a/.github/workflows/mf6.yml b/.github/workflows/mf6.yml index 32ed85c17c..72011cdfc4 100644 --- a/.github/workflows/mf6.yml +++ b/.github/workflows/mf6.yml @@ -49,8 +49,7 @@ jobs: - name: Checkout MODFLOW 6 uses: actions/checkout@v4 with: - repository: wpbonelli/modflow6 - ref: numpy2-fixes + repository: MODFLOW-USGS/modflow6 path: modflow6 - name: Build and install MF6 From ee9953389227c11f5ca6324a3046e146c2298b6e Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Wed, 19 Jun 2024 00:07:06 -0400 Subject: [PATCH 8/8] remove temp np2 version pins --- etc/environment.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/environment.yml b/etc/environment.yml index 873b23c634..504f80c86c 100644 --- a/etc/environment.yml +++ b/etc/environment.yml @@ -6,6 +6,7 @@ dependencies: # required - python>=3.8 + - numpy>=1.20.3 - matplotlib>=1.4.0 - pandas>=2.0.0 @@ -21,7 +22,6 @@ dependencies: - jupyter_client>=8.4.0 - jupytext - pip: - - numpy>=2.0.0 - git+https://github.com/MODFLOW-USGS/modflow-devtools.git - pytest!=8.1.0 - pytest-benchmark diff --git a/pyproject.toml b/pyproject.toml index 08774c3ac5..f53c5e6cd5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "numpy >=2.0.0", + "numpy>=1.20.3", "matplotlib >=1.4.0", "pandas >=2.0.0" ]