Skip to content

Commit

Permalink
relax voronoi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 4, 2024
1 parent a06befa commit 53b4d9a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions autotest/test_prt_voronoi1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

from pathlib import Path
from platform import processor, system

import flopy
import matplotlib as mpl
Expand All @@ -24,7 +23,6 @@
from flopy.utils.voronoi import VoronoiGrid
from framework import TestFramework
from modflow_devtools.markers import requires_pkg
from modflow_devtools.misc import is_in_ci
from prt_test_utils import get_model_name
from shapely.geometry import LineString, Point

Expand Down Expand Up @@ -245,12 +243,16 @@ def build_models(idx, test):
return gwf_sim, prt_sim


def plot_output(name, gwf, head, spdis, pls, fpath):
def plot_output(name, gwf, head, spdis, pls, fpath, diff=None):
# plot in 2d with mpl
fig = plt.figure(figsize=(16, 10))
ax = plt.subplot(1, 1, 1, aspect="equal")
pmv = flopy.plot.PlotMapView(model=gwf, ax=ax)
pmv.plot_grid(alpha=0.25)

if diff:
ax.scatter(diff.x, diff.y, c="red")

pmv.plot_ibound(alpha=0.5)
headmesh = pmv.plot_array(head, alpha=0.25)
cv = pmv.contour_array(head, levels=np.linspace(0, 1, 9), colors="black")
Expand Down Expand Up @@ -348,7 +350,7 @@ def callback(mesh, value):
p.show()


def check_output(idx, test, snapshot):
def check_output(idx, test):
name = test.name
prt_ws = test.workspace / "prt"
prt_name = get_model_name(name, "prt")
Expand All @@ -365,15 +367,12 @@ def check_output(idx, test, snapshot):
prt_track_csv_file = f"{prt_name}.prp.trk.csv"
pls = pd.read_csv(prt_ws / prt_track_csv_file, na_filter=False)
endpts = pls[pls.ireason == 3] # termination
# endpts.drop("icell", axis=1, inplace=True)

# compare pathlines with snapshot. particles shouldn't
# have moved vertically. round for cross-platform error.
# skip macos-14 in CI because grid is slightly different
if not (is_in_ci() and system() == "Darwin" and processor() == "arm"):
assert snapshot == endpts.drop("name", axis=1).round(1).to_records(index=False)
assert np.allclose(endpts.z, 0.5)
assert np.isclose(endpts.y.min(), 1, atol=4)
assert np.isclose(endpts.y.max(), 996, atol=4)

# pl# ot results if enabled
# plot results if enabled
plot = False
if plot:
plot_output(name, gwf, head, (qx, qy), pls, fpath=prt_ws / f"{name}.png")
Expand All @@ -382,12 +381,12 @@ def check_output(idx, test, snapshot):
@requires_pkg("syrupy")
@pytest.mark.slow
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets, benchmark, array_snapshot):
def test_mf6model(idx, name, function_tmpdir, targets, benchmark):
test = TestFramework(
name=name,
workspace=function_tmpdir,
build=lambda t: build_models(idx, t),
check=lambda t: check_output(idx, t, array_snapshot),
check=lambda t: check_output(idx, t),
targets=targets,
compare=None,
)
Expand Down

0 comments on commit 53b4d9a

Please sign in to comment.