fix(utils): fix zone off-by-one, add test for #2612 - #2818
Merged
Conversation
…add PRT The original modflowpy#2612 repro built no PRT model despite its docstring claiming to compare PRT to MP7, and only checked that Modpath7Sim didn't raise on 2D/3D zones arrays -- with no boundary conditions the lone default particle terminated immediately without ever crossing between zones, so the test never exercised zone semantics at all. Rework it against a small DISV grid with real CHD-driven flow, where a particle released upstream of a stopzone cell must pass through it before reaching a sink cell. This lets the test assert the particle is actually intercepted by the zone (not just that construction doesn't crash), and that the 2D (nlay, ncpl) and 3D (nlay, 1, ncpl) zones arrays are interpreted identically by Util3d, which is the actual substance of the issue. Also add the promised PRT model: PRT's izone (MIP package) takes a native 2D griddata array for DISV grids, so it serves as a second reference implementation to check MP7's zone behavior against. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbPuZ3nFWeCKM5Rpmpvmo
EndpointFile.kijnames lumped "zone0"/"zone" in with the k/i/j/node fields that get -1 applied to convert MODPATH 7's 1-based Fortran indices to 0-based. But zone numbers are user-assigned labels, not positional indices -- MP7 writes them unshifted (verified against a raw .mpend record: a cell tagged zone 2 is written as "2", not "3"), so every zone value read back through EndpointFile was silently off by one. Found while building a zones-focused regression test for modflowpy#2612 that actually checks a stopzone value against the endpoint file rather than just the input zones array. Nothing else in flopy reads zone/ zone0 from parsed endpoint data (searched plot/export code and autotest/), so this only affects direct EndpointFile consumers who were compensating for the off-by-one themselves. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbPuZ3nFWeCKM5Rpmpvmo
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2818 +/- ##
===========================================
+ Coverage 55.5% 73.3% +17.8%
===========================================
Files 644 659 +15
Lines 124135 132188 +8053
===========================================
+ Hits 68947 97013 +28066
+ Misses 55188 35175 -20013
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two separate things. Fix an off-by-one bug in EndpointFile: zone numbers read back from a MODPATH 7 endpoint file were silently decremented by 1. And add a test reproducing #2613. Bisect confirms the issue was fixed some time ago by #1415.