Skip to content

Commit 198ed1c

Browse files
committed
test: accommodate slight triangle grid variations
1 parent fe620d5 commit 198ed1c

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

autotest/test_grid.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,17 +1492,9 @@ def test_voronoi_grid(request, function_tmpdir, grid_case):
14921492
name = request.node.name.replace("/", "_").replace("\\", "_").replace(":", "_")
14931493
ncpl, vor, gridprops, grid = grid_case()
14941494

1495-
# TODO: debug off-by-3 issue
1496-
# could be a rounding error as described here:
1497-
# https://github.com/modflowpy/flopy/issues/1492#issuecomment-1210596349
1498-
1499-
# ensure proper number of cells
1500-
almost_right = ncpl == 538 and gridprops["ncpl"] == 535
1501-
if almost_right:
1502-
warn("off-by-3")
1503-
15041495
# ensure that all cells have 3 or more points
15051496
invalid_cells = [i for i, ivts in enumerate(vor.iverts) if len(ivts) < 3]
1497+
assert len(invalid_cells) == 0
15061498

15071499
# make a plot including invalid cells
15081500
fig = plt.figure(figsize=(10, 10))
@@ -1512,10 +1504,12 @@ def test_voronoi_grid(request, function_tmpdir, grid_case):
15121504
ax.plot(grid.xcellcenters[invalid_cells], grid.ycellcenters[invalid_cells], "ro")
15131505
plt.savefig(function_tmpdir / f"{name}.png")
15141506

1515-
assert ncpl == gridprops["ncpl"] or almost_right
1516-
assert len(invalid_cells) == 0, (
1517-
f"The following cells do not have 3 or more vertices.\n{invalid_cells}"
1518-
)
1507+
# ensure proper number of cells. the grid may be slightly different
1508+
# on different platforms depending which compiler triangle is built
1509+
# with, so allow small variations.
1510+
tol = 3
1511+
assert abs(ncpl - gridprops["ncpl"]) <= tol
1512+
assert len(invalid_cells) == 0
15191513

15201514

15211515
@pytest.fixture

0 commit comments

Comments
 (0)