diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 27f13ea..055cf65 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/setup-python@v2 with: - python-version: "3.7" + python-version: "3.9" - uses: actions/checkout@v2 - name: Lint with flake8 run: | @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, '3.10' ] + python-version: [ 3.8, 3.9, '3.10', '3.11'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/oceanmesh/clean.py b/oceanmesh/clean.py index d1d4f98..ec31ad0 100644 --- a/oceanmesh/clean.py +++ b/oceanmesh/clean.py @@ -471,7 +471,7 @@ def _closest_node(node, nodes): L[L < eps] = eps L = L[:, None] for it in range(max_iter): - pnew = np.divide(S * np.matrix(vertices), np.hstack((W, W))) + pnew = np.divide(S @ np.array(vertices), np.hstack((W, W))) pnew[bnd, :] = vertices[bnd, :] vertices = pnew Lnew = np.sqrt( diff --git a/oceanmesh/edgefx.py b/oceanmesh/edgefx.py index d2ebba7..65a330a 100644 --- a/oceanmesh/edgefx.py +++ b/oceanmesh/edgefx.py @@ -7,11 +7,11 @@ import numpy as np import scipy.spatial import skfmm +from _HamiltonJacobi import gradient_limit from inpoly import inpoly2 from shapely.geometry import LineString from skimage.morphology import medial_axis -from _HamiltonJacobi import gradient_limit from oceanmesh.filterfx import filt2 from . import edges diff --git a/oceanmesh/fix_mesh.py b/oceanmesh/fix_mesh.py index 8e3be27..da39ea5 100644 --- a/oceanmesh/fix_mesh.py +++ b/oceanmesh/fix_mesh.py @@ -96,8 +96,10 @@ def unique_rows(A, return_index=False, return_inverse=False): orig_dtype = A.dtype ncolumns = A.shape[1] - dtype = np.dtype((np.character, orig_dtype.itemsize * ncolumns)) + dtype = np.dtype((f"S{orig_dtype.itemsize * ncolumns}")) B, I, J = np.unique(A.view(dtype), return_index=True, return_inverse=True) + # NUMPY 2 compatibility + J = J.reshape(-1) B = B.view(orig_dtype).reshape((-1, ncolumns), order="C") diff --git a/oceanmesh/geodata.py b/oceanmesh/geodata.py index d7268d6..00af47d 100644 --- a/oceanmesh/geodata.py +++ b/oceanmesh/geodata.py @@ -669,7 +669,7 @@ def _read(self): raise ValueError(f"Unsupported geometry type: {g.geom_type}") poly = remove_dup(poly) - polys.append(np.row_stack((poly, delimiter))) + polys.append(np.vstack((poly, delimiter))) if len(polys) == 0: raise ValueError("Shoreline data does not intersect with bbox") @@ -794,9 +794,9 @@ def __init__(self, dem, crs="EPSG:4326", bbox=None, extrapolate=False): topobathy = np.transpose(topobathy, (1, 0)) # Ensure its a floating point array topobathy = topobathy.astype(np.float64) - topobathy[ - topobathy == nodata_value - ] = np.nan # set the no-data value to nan + topobathy[topobathy == nodata_value] = ( + np.nan + ) # set the no-data value to nan elif not dem.exists(): raise FileNotFoundError(f"File {dem} could not be located.") diff --git a/oceanmesh/idw.py b/oceanmesh/idw.py index f71b8fa..a165118 100644 --- a/oceanmesh/idw.py +++ b/oceanmesh/idw.py @@ -1,6 +1,7 @@ """ invdisttree.py: inverse-distance-weighted interpolation using KDTree fast, solid, local """ + from __future__ import division import numpy as np diff --git a/oceanmesh/mesh_generator.py b/oceanmesh/mesh_generator.py index 06ae670..889cbbf 100644 --- a/oceanmesh/mesh_generator.py +++ b/oceanmesh/mesh_generator.py @@ -7,7 +7,6 @@ import matplotlib.tri as tri import numpy as np import scipy.sparse as spsparse - from _delaunay_class import DelaunayTriangulation as DT from _fast_geometry import unique_edges diff --git a/pyproject.toml b/pyproject.toml index bf5a947..f4c6b52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,4 +3,4 @@ requires = ["setuptools>=42", "wheel", "pybind11>=2.6.0", "versioneer-518"] build-backend = "setuptools.build_meta" [tool.black] -target-version = ['py37'] \ No newline at end of file +target-version = ['py39'] diff --git a/setup.cfg b/setup.cfg index 7fa8341..6d2d3ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,7 @@ install_requires = pyproj scipy geopandas + fiona shapely matplotlib rasterio>=1.3a1 diff --git a/setup.py b/setup.py index a19dafa..c271861 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import os import sys +import configparser from pybind11.setup_helpers import Pybind11Extension, build_ext from setuptools import setup # , find_packages @@ -44,8 +45,26 @@ cmdclass = versioneer.get_cmdclass() cmdclass.update({"build_ext": build_ext}) + +def get_requirements(): + """ + Fix + """ + + config = configparser.ConfigParser() + config.read("setup.cfg") + requirements = config["options"]["install_requires"].split() + + if sys.version_info < (3, 9): + requirements.remove("fiona") + requirements.append("fiona<1.10") + + return requirements + + if __name__ == "__main__": setup( + install_requires=get_requirements(), cmdclass=cmdclass, version=versioneer.get_version(), ext_modules=ext_modules, diff --git a/tests/test_bathymetric_gradient_function.py b/tests/test_bathymetric_gradient_function.py index 0bb0d72..c91c23d 100644 --- a/tests/test_bathymetric_gradient_function.py +++ b/tests/test_bathymetric_gradient_function.py @@ -1,6 +1,7 @@ import os import pytest + import oceanmesh as om fname = os.path.join(os.path.dirname(__file__), "GSHHS_i_L1.shp")