Skip to content

Commit

Permalink
Shapely now supports NumPy 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomodeller committed Aug 20, 2024
1 parent 02773ad commit 5f6df16
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ jobs:
- name: Install mikeio
run: |
pip install .[dev]
- name: Install pinned version of Numpy
# Numpy 2.1 causes problems with shapely
run: |
pip install numpy==2.0.0
- name: Build documentation
run: |
Expand Down
7 changes: 3 additions & 4 deletions tests/test_dfsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,10 @@ def test_read_area_polygon():

assert ds.geometry.n_elements < dfs.geometry.n_elements

# TODO fails with Numpy 2.1.0
# domain = dfs.geometry.to_shapely().buffer(0)
# subdomain = ds.geometry.to_shapely().buffer(0)
domain = dfs.geometry.to_shapely().buffer(0)
subdomain = ds.geometry.to_shapely().buffer(0)

# assert subdomain.within(domain)
assert subdomain.within(domain)


def test_read_elements():
Expand Down
11 changes: 5 additions & 6 deletions tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ def test_write_mesh_from_dfsu(tmp_path):
assert np.all(np.hstack(msh2.element_table) == np.hstack(geometry.element_table))


# TODO doesn't run with Numpy 2.1.0
# def test_to_shapely(tri_mesh) -> None:
# msh = tri_mesh
# shp = msh.to_shapely()
# assert shp.geom_type == "MultiPolygon"
# assert shp.area == pytest.approx(68931409.58160606)
def test_to_shapely(tri_mesh) -> None:
msh = tri_mesh
shp = msh.to_shapely()
assert shp.geom_type == "MultiPolygon"
assert shp.area == pytest.approx(68931409.58160606)
27 changes: 13 additions & 14 deletions tests/test_shapely.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

# from mikeio.spatial._FM_geometry import GeometryFM2D
from mikeio.spatial import GeometryFM2D


##################################################
Expand All @@ -9,18 +9,17 @@
pytest.importorskip("shapely")


# TODO doesn't run with Numpy 2.1.0
# def test_to_shapely():
# # x y z
# nc = [
# (0.0, 0.0, 0.0), # 0
# (1.0, 0.0, 0.0), # 1
# (0.5, 1.0, 0.0), # 2
# ]
def test_to_shapely():
# x y z
nc = [
(0.0, 0.0, 0.0), # 0
(1.0, 0.0, 0.0), # 1
(0.5, 1.0, 0.0), # 2
]

# el = [(0, 1, 2)]
el = [(0, 1, 2)]

# g = GeometryFM2D(nc, el)
# shp = g.to_shapely()
# assert shp.geom_type == "MultiPolygon"
# assert shp.area == 0.5
g = GeometryFM2D(nc, el)
shp = g.to_shapely()
assert shp.geom_type == "MultiPolygon"
assert shp.area == 0.5

0 comments on commit 5f6df16

Please sign in to comment.