Skip to content

Commit 478fe78

Browse files
authored
Upgrade NumPy and python (#83)
* Make compatible with numpy 2.0.0
1 parent a017890 commit 478fe78

File tree

11 files changed

+34
-11
lines changed

11 files changed

+34
-11
lines changed

.github/workflows/testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/setup-python@v2
1414
with:
15-
python-version: "3.7"
15+
python-version: "3.9"
1616
- uses: actions/checkout@v2
1717
- name: Lint with flake8
1818
run: |
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: [3.7, 3.8, 3.9, '3.10' ]
30+
python-version: [ 3.8, 3.9, '3.10', '3.11']
3131
steps:
3232
- uses: actions/checkout@v2
3333
- name: Set up Python ${{ matrix.python-version }}

oceanmesh/clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def _closest_node(node, nodes):
471471
L[L < eps] = eps
472472
L = L[:, None]
473473
for it in range(max_iter):
474-
pnew = np.divide(S * np.matrix(vertices), np.hstack((W, W)))
474+
pnew = np.divide(S @ np.array(vertices), np.hstack((W, W)))
475475
pnew[bnd, :] = vertices[bnd, :]
476476
vertices = pnew
477477
Lnew = np.sqrt(

oceanmesh/edgefx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import numpy as np
88
import scipy.spatial
99
import skfmm
10+
from _HamiltonJacobi import gradient_limit
1011
from inpoly import inpoly2
1112
from shapely.geometry import LineString
1213
from skimage.morphology import medial_axis
1314

14-
from _HamiltonJacobi import gradient_limit
1515
from oceanmesh.filterfx import filt2
1616

1717
from . import edges

oceanmesh/fix_mesh.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def unique_rows(A, return_index=False, return_inverse=False):
9696

9797
orig_dtype = A.dtype
9898
ncolumns = A.shape[1]
99-
dtype = np.dtype((np.character, orig_dtype.itemsize * ncolumns))
99+
dtype = np.dtype((f"S{orig_dtype.itemsize * ncolumns}"))
100100
B, I, J = np.unique(A.view(dtype), return_index=True, return_inverse=True)
101+
# NUMPY 2 compatibility
102+
J = J.reshape(-1)
101103

102104
B = B.view(orig_dtype).reshape((-1, ncolumns), order="C")
103105

oceanmesh/geodata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def _read(self):
669669
raise ValueError(f"Unsupported geometry type: {g.geom_type}")
670670

671671
poly = remove_dup(poly)
672-
polys.append(np.row_stack((poly, delimiter)))
672+
polys.append(np.vstack((poly, delimiter)))
673673

674674
if len(polys) == 0:
675675
raise ValueError("Shoreline data does not intersect with bbox")
@@ -794,9 +794,9 @@ def __init__(self, dem, crs="EPSG:4326", bbox=None, extrapolate=False):
794794
topobathy = np.transpose(topobathy, (1, 0))
795795
# Ensure its a floating point array
796796
topobathy = topobathy.astype(np.float64)
797-
topobathy[
798-
topobathy == nodata_value
799-
] = np.nan # set the no-data value to nan
797+
topobathy[topobathy == nodata_value] = (
798+
np.nan
799+
) # set the no-data value to nan
800800
elif not dem.exists():
801801
raise FileNotFoundError(f"File {dem} could not be located.")
802802

oceanmesh/idw.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" invdisttree.py: inverse-distance-weighted interpolation using KDTree
22
fast, solid, local
33
"""
4+
45
from __future__ import division
56

67
import numpy as np

oceanmesh/mesh_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import matplotlib.tri as tri
88
import numpy as np
99
import scipy.sparse as spsparse
10-
1110
from _delaunay_class import DelaunayTriangulation as DT
1211
from _fast_geometry import unique_edges
1312

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ requires = ["setuptools>=42", "wheel", "pybind11>=2.6.0", "versioneer-518"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.black]
6-
target-version = ['py37']
6+
target-version = ['py39']

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ install_requires =
2828
pyproj
2929
scipy
3030
geopandas
31+
fiona
3132
shapely
3233
matplotlib
3334
rasterio>=1.3a1

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import configparser
34

45
from pybind11.setup_helpers import Pybind11Extension, build_ext
56
from setuptools import setup # , find_packages
@@ -44,8 +45,26 @@
4445
cmdclass = versioneer.get_cmdclass()
4546
cmdclass.update({"build_ext": build_ext})
4647

48+
49+
def get_requirements():
50+
"""
51+
Fix
52+
"""
53+
54+
config = configparser.ConfigParser()
55+
config.read("setup.cfg")
56+
requirements = config["options"]["install_requires"].split()
57+
58+
if sys.version_info < (3, 9):
59+
requirements.remove("fiona")
60+
requirements.append("fiona<1.10")
61+
62+
return requirements
63+
64+
4765
if __name__ == "__main__":
4866
setup(
67+
install_requires=get_requirements(),
4968
cmdclass=cmdclass,
5069
version=versioneer.get_version(),
5170
ext_modules=ext_modules,

0 commit comments

Comments
 (0)