Skip to content

Commit

Permalink
fix(GridIntersect): fix DeprecationWarnings for Shapely2.0 (modflowpy…
Browse files Browse the repository at this point in the history
…#1504)

* refactor(make-release): Software citation developed from version.py

Closes modflowpy#727

* release: update mf6 v6.1.1 dfn and flopy mf6 classes (#1)

* docs(misc): clean up docstrings

* refactor(GridIntersect): fix error message
for unsupported methods

* bug(GridIntersect): fix #10
ensure one entry per grid cell in polygon intersection result
add test for this case

* bug(gridintersect): fixes modflowpy#917

bug in structured mode where linestrings were not handled
correctly if they pass in and out of grid cell

* fix(GridIntersect): modflowpy#1035
- fix vertices when intersecting linestring with offset grids

* fix shapely2.0 deprecation warnings
- keep separate lists of cellids and geometries
- use .geoms for iteration over multipart geoms
- add deprecation warnings to old methods to generate list of geoms
- update intersect_* methods to use new STRtree api
- update tests
- add replacement function for deprecated descartes PolygonPatch

* update notebook

* run black, isort, docformatter

* update to new STRtree implementation
filter shapely2 warnings
add shapely<1.8 exception
update shapely warning filtering since shapely>1.8 required

* address @jlarsen-usgs review comments

* quick fix to get_lrc call

Changed
```python
mfgrid.get_lrc([node])[1:]
```
to
```python
mfgrid.get_lrc([node])[0][1:]
```

* change list to tuple in get_node()

Co-authored-by: jdhughes-usgs <jdhughes@usgs.gov>
Co-authored-by: Christian Langevin <langevin@usgs.gov>
Co-authored-by: Joshua Larsen <jlarsen@usgs.gov>
  • Loading branch information
4 people authored and wpbonelli committed Dec 14, 2022
1 parent 80c4b58 commit dfc51d9
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 558 deletions.
11 changes: 8 additions & 3 deletions autotest/test_gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_rect_grid_linestring_in_and_out_of_cell2():
def test_rect_grid_linestrings_on_boundaries_return_all_ix():
gr = get_rect_grid()
ix = GridIntersect(gr, method="structured")
x, y = ix._rect_grid_to_shape_list()[0].exterior.xy
x, y = ix._rect_grid_to_geoms_cellids()[0][0].exterior.xy
n_intersections = [1, 2, 2, 1]
for i in range(4):
ls = LineString([(x[i], y[i]), (x[i + 1], y[i + 1])])
Expand Down Expand Up @@ -584,7 +584,7 @@ def test_rect_grid_linestring_in_and_out_of_cell_shapely(rtree):
def test_rect_grid_linestrings_on_boundaries_return_all_ix_shapely(rtree):
gr = get_rect_grid()
ix = GridIntersect(gr, method="vertex", rtree=rtree)
x, y = ix._rect_grid_to_shape_list()[0].exterior.xy
x, y = ix._rect_grid_to_geoms_cellids()[0][0].exterior.xy
n_intersections = [1, 2, 2, 1]
for i in range(4):
ls = LineString([(x[i], y[i]), (x[i + 1], y[i + 1])])
Expand Down Expand Up @@ -670,7 +670,7 @@ def test_tri_grid_multilinestring_in_one_cell(rtree):
def test_tri_grid_linestrings_on_boundaries_return_all_ix(rtree):
tgr = get_tri_grid()
ix = GridIntersect(tgr, method="vertex", rtree=rtree)
x, y = ix._vtx_grid_to_shape_list()[0].exterior.xy
x, y = ix._vtx_grid_to_geoms_cellids()[0][0].exterior.xy
n_intersections = [2, 1, 2]
for i in range(len(x) - 1):
ls = LineString([(x[i], y[i]), (x[i + 1], y[i + 1])])
Expand Down Expand Up @@ -1297,3 +1297,8 @@ def test_raster_sampling_methods(example_data_path):
raise AssertionError(
f"{method} resampling returning incorrect values"
)


if __name__ == "__main__":

test_all_intersections_shapely_no_strtree()
Loading

0 comments on commit dfc51d9

Please sign in to comment.