Skip to content

Commit

Permalink
tests: make sure the tests pass
Browse files Browse the repository at this point in the history
also address some deprecation warnings
  • Loading branch information
brey committed Jul 10, 2024
1 parent 81e4d68 commit 5ada7bc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
15 changes: 9 additions & 6 deletions pyposeidon/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def buffer_(coasts, cbuffer):
ww_.loc[idx] = b

# join
wu = ww_.unary_union
wu = ww_.union_all()
wu = gp.GeoDataFrame(geometry=[wu]).explode(index_parts=True).droplevel(0).reset_index(drop=True)

rings = wu.boundary.is_ring # get multiple boundaries instance
Expand Down Expand Up @@ -309,7 +309,7 @@ def tag(geometry, coasts, cbuffer, blevels):
else:
try:
gw = gp.GeoDataFrame(
geometry=list(ww.buffer(0).unary_union)
geometry=list(ww.buffer(0).union_all())
) # merge the polygons that are split (around -180/180)
except:
gw = gp.GeoDataFrame(geometry=list(ww.values))
Expand Down Expand Up @@ -342,7 +342,7 @@ def tag(geometry, coasts, cbuffer, blevels):
block = coasts.copy()

if not block.empty:
g = block.unary_union.symmetric_difference(grp) # get the dif from the coasts
g = block.union_all().symmetric_difference(grp) # get the dif from the coasts
else:
g = grp

Expand Down Expand Up @@ -529,9 +529,12 @@ def global_tag(geo, cbuffer, blevels, R=1):

ww = gp.GeoDataFrame(geometry=cs)

gw = gp.GeoDataFrame(
geometry=list(ww.buffer(0).unary_union.geoms)
) # merge the polygons that are split (around -180/180)
ww_ = ww.buffer(0).union_all()

if ww_.geom_type == "Polygon":
gw = gp.GeoDataFrame(geometry=[ww_])
else:
gw = gp.GeoDataFrame(geometry=list(ww_.geoms)) # merge the polygons that are split (around -180/180)

gw = gp.GeoDataFrame(geometry=gw.boundary.values)

Expand Down
8 changes: 4 additions & 4 deletions pyposeidon/dem_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def fix(dem, coastline, **kwargs):
block = shp.cx[minlon:maxlon, minlat:maxlat]

try:
block = gp.GeoDataFrame(geometry=list(block.unary_union.geoms))
block = gp.GeoDataFrame(geometry=list(block.union_all().geoms))
except:
pass

Expand All @@ -189,7 +189,7 @@ def fix(dem, coastline, **kwargs):
grp = grp.buffer(0.5) # buffer it to get also the boundary points

try:
g = block.unary_union.symmetric_difference(grp) # get the diff
g = block.union_all().symmetric_difference(grp) # get the diff
except:
g = grp # no land

Expand All @@ -208,7 +208,7 @@ def fix(dem, coastline, **kwargs):
except:
b = shapely.geometry.GeometryCollection()

b = b.unary_union
b = b.union_all()

# define wet/dry
water = b
Expand Down Expand Up @@ -497,7 +497,7 @@ def check2(dataset, coastline):
else:
coasts = coastline

cc = coasts.unary_union
cc = coasts.union_all()

wn = tree.query(cc, predicate="intersects").tolist()

Expand Down
4 changes: 2 additions & 2 deletions pyposeidon/mgmsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def read_msh(filename, **kwargs):
# nodes, tria = orient(nodes, tria, x="x", y="y")
# else:
bgmesh = kwargs.get("bgmesh", None)
if not bgmesh:
tria = tria.reindex(columns=["a", "c", "b"])
# if not bgmesh:
# tria = tria.reindex(columns=["a", "c", "b"])

# check if global and reproject
if gglobal: # convert to lat/lon
Expand Down
2 changes: 1 addition & 1 deletion pyposeidon/utils/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def run(self, **kwargs):

copy = get_value(self, kwargs, "copy", False)

ihot = get_value(self, kwargs, "ihot", 1)
ihot = get_value(self, kwargs, "ihot", 2)

pwd = os.getcwd()

Expand Down
6 changes: 3 additions & 3 deletions tests/test_schism_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_schism_cast_workflow(tmpdir):
if not total.Dataset[var].equals(output.Dataset[var]):
rb.append(var)

print(rb)
# print(rb)

# flag = True TODO
# for var in rb:
Expand All @@ -208,5 +208,5 @@ def test_schism_cast_workflow(tmpdir):
# flag = True
# print(mdif)

expected = ["wetdry_side", "wetdry_elem", "wetdry_node", "zcor", "elev", "hvel"]
assert rb == expected
# expected = ["wetdry_side", "wetdry_elem", "wetdry_node", "zcor", "elev", "hvel"]
assert (rb == ["zcor"]) or (rb == [])
6 changes: 3 additions & 3 deletions tests/test_schism_reforecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_schism_reforecast_workflow(tmpdir):
if not total.Dataset[var].equals(r[var]):
rb.append(var)

print(rb)
# print(rb)

# flag = True TODO
# for var in rb:
Expand All @@ -166,5 +166,5 @@ def test_schism_reforecast_workflow(tmpdir):
# if mdif < 1.e-14 :
# flag = True
# print(mdif)
expected = ["wetdry_side", "wetdry_elem", "wetdry_node", "zcor", "elev", "hvel"]
assert rb == expected
# expected = ["wetdry_side", "wetdry_elem", "wetdry_node", "zcor", "elev", "hvel"]
assert (rb == ["zcor"]) or (rb == [])

0 comments on commit 5ada7bc

Please sign in to comment.