Repository navigation
fix(dfns): type number-or-word fields as unions - #389
Merged
Merged
Conversation
v1 types a few fields `string` when MF6 reads a number from them. LAK's `bedleak` takes a number or NONE, and MAW's `head_limit` a number or OFF. The migration now makes each an untagged union, a keyword arm tried before a double arm. A union can't be a union's arm, so MAW's `head_limit` arm becomes a record, `HEAD_LIMIT <head_limit_value>`. It also retypes UZF's seven `string` time-series period values as `double`. mf6 made the same change on develop after 6.8.1 (#2786), so the migration also accepts DFNs that already have it. Both fixup tables raise if a named field is missing or has an unexpected type, so they can't silently go stale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wpbonelli
marked this pull request as ready for review
October 12, 2026 16:20
wpbonelli
added a commit
to modflowpy/pyphoenix-project
that referenced
this pull request
Oct 13, 2026
Use MODFLOW-ORG/modflow-devtools#389 and MODFLOW-ORG/modflow-devtools#391 for consistent list field typing Up to now some packages' period data has been typed as a list of records, where the record is just a leading feature number followed by a union. Codegen used to copy the index into each of the union arms to artificially produce a list of unions. This gave a slightly less verbose API at the cost of harder-to-predict typing. Remove this so the generated field typing follows the DFNs predictably. # before Maw.Status(ifno=0, status="active") Maw.HeadLimit(ifno=1, head_limit="off") # after Maw.StressPeriodData(ifno=0, mawsetting=Maw.Status(status="active")) Maw.StressPeriodData(ifno=1, mawsetting=Maw.HeadLimit(head_limit="OFF")) # mixing typed and raw format works too Maw.StressPeriodData(ifno=0, mawsetting=("status", "active")). Plain tuples like (0, "STATUS", "ACTIVE") can still be passed instead of the typed form. This all applies to MAW, LKT, LKE, SFR, SPC, TVK and TVS Other changes: * OC settings become literals, the quickstart changed because of this * str fields no longer accept numbers, that must be typed as a union
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.
v1 types a few fields
stringwhere the value may be a word or a numberbedleaktakes a number or "NONE"head_limita number or "OFF"Make these unions instead.
Also retype UZF's
stringtime-series period fields asdouble. MF6 made the same change on develop after 6.8.1 (#2786), so accept DFNs that already have it