Skip to content

fix(dfns): type number-or-word fields as unions - #389

Merged
wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:number-or-word-unions
Oct 12, 2026
Merged

wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:number-or-word-unions

Conversation

@wpbonelli

@wpbonelli wpbonelli commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

v1 types a few fields string where the value may be a word or a number

  • LAK's bedleak takes a number or "NONE"
  • MAW's head_limit a number or "OFF"

Make these unions instead.

Also retype UZF's string time-series period fields as double. MF6 made the same change on develop after 6.8.1 (#2786), so accept DFNs that already have it

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 wpbonelli added this to the 1.10.0 milestone Oct 12, 2026
@wpbonelli wpbonelli added the bug Something isn't working label Oct 12, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review October 12, 2026 16:20
@wpbonelli
wpbonelli merged commit 601c1b1 into MODFLOW-ORG:develop Oct 12, 2026
17 checks passed
@wpbonelli
wpbonelli deleted the number-or-word-unions branch October 12, 2026 16:22
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant