Skip to content

fix(datafile): fix mixed-text file behavior#2714

Open
wpbonelli wants to merge 5 commits intomodflowpy:developfrom
wpbonelli:binarylayerfile
Open

fix(datafile): fix mixed-text file behavior#2714
wpbonelli wants to merge 5 commits intomodflowpy:developfrom
wpbonelli:binarylayerfile

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Feb 19, 2026

This PR builds on #2231.

Ignoring text breaks the only mechanism to access secondary record types in a mixed-text file (e.g. DRAWDOWN in a HEAD+DRAWDOWN file).

Keep text functional. The new headers can contain all of the headers in the file, regardless of record type, while recordarray holds only records of type text.

Keep doing substring matching when filtering by text.

Make BinaryLayerFile public. Default text=None and automatically read it from the first header in the file. Warn on mixed-text files i.e. more than one record type.

Add a unique_records property which will in most cases have a single element, multiple for mixed-text files.

I think it's cleanest for these file handle classes to scope to a single record type like this. With the addition of headers and unique_records one can easily see if a file is mixed-text, then open separate handles for the other record types.

BinaryLayerFile becomes the recommended entry point for MF6 advanced package output files (LAK, SFR, UZF, etc.) where the text label isn't known in advance, so we avoid the HeadFile naming mismatch.

Child class defaults stay the same: HeadFile(text="head"), UcnFile(text="concentration"), HeadUFile(text="headu"). Raise if no records matching the given text are found. So HeadFile("model.ddn") will error. But HeadFile("model.ddn", text="drawdown") or BinaryLayerFile("model.ddn") will work.

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 75.64103% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.4%. Comparing base (556c088) to head (0844df4).
⚠️ Report is 131 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/utils/binaryfile/__init__.py 84.3% 10 Missing ⚠️
flopy/export/utils.py 16.6% 5 Missing ⚠️
flopy/mf6/utils/binaryfile_utils.py 0.0% 2 Missing ⚠️
flopy/export/vtk.py 0.0% 1 Missing ⚠️
flopy/utils/datafile.py 75.0% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2714      +/-   ##
===========================================
+ Coverage     55.5%    72.4%   +16.8%     
===========================================
  Files          644      674      +30     
  Lines       124135   130634    +6499     
===========================================
+ Hits         68947    94585   +25638     
+ Misses       55188    36049   -19139     
Files with missing lines Coverage Δ
flopy/utils/__init__.py 100.0% <100.0%> (ø)
flopy/export/vtk.py 68.4% <0.0%> (-9.7%) ⬇️
flopy/utils/datafile.py 71.6% <75.0%> (-2.7%) ⬇️
flopy/mf6/utils/binaryfile_utils.py 10.6% <0.0%> (-42.1%) ⬇️
flopy/export/utils.py 53.6% <16.6%> (-11.0%) ⬇️
flopy/utils/binaryfile/__init__.py 82.2% <84.3%> (-2.3%) ⬇️

... and 566 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpbonelli wpbonelli marked this pull request as ready for review February 20, 2026 00:58
@wpbonelli wpbonelli requested a review from mwtoews February 20, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments