Skip to content

Commit

Permalink
refactor(dependencies): support numpy 2 (#2241)
Browse files Browse the repository at this point in the history
Remove NumPy upper bound to close #2153. Also fix `@requires_pkg` usage in `test_export.py`, replace deprecated `itemset` in `mfdatastorage.py`, and bump some CI jobs to Python 3.9.

This PR required updates on the MF6 side:

* test(test_gwf_maw04.py): switch deprecated np.unicode_ -> np.str_ MODFLOW-USGS/modflow6#1886
* test(prt): omit name field (object dtype) from snapshots MODFLOW-USGS/modflow6#1887
  • Loading branch information
wpbonelli authored Jun 19, 2024
1 parent 59040d0 commit e48198c
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 23 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
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'
defaults:
run:
shell: bash -l {0}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
shell: bash
timeout-minutes: 10
env:
PYTHON_VERSION: 3.8
PYTHON_VERSION: 3.9

steps:
- name: Checkout repo
Expand Down Expand Up @@ -134,10 +134,6 @@ jobs:
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'
defaults:
run:
shell: bash -l {0}
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
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'
defaults:
run:
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/optional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
shell: bash
timeout-minutes: 10
env:
PYTHON_VERSION: 3.8
PYTHON_VERSION: 3.9
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions autotest/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion etc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:

# required
- python>=3.8
- numpy>=1.20.3,<2.0.0
- numpy>=1.20.3
- matplotlib>=1.4.0
- pandas>=2.0.0

Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/data/mfdatastorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"numpy >=1.20.3,<2.0.0",
"numpy>=1.20.3",
"matplotlib >=1.4.0",
"pandas >=2.0.0"
]
Expand Down

0 comments on commit e48198c

Please sign in to comment.