Skip to content

conditional fields - #473

Merged
wpbonelli merged 8 commits into
modflowpy:developfrom
wpbonelli:option-columns
Oct 15, 2026
Merged

wpbonelli merged 8 commits into
modflowpy:developfrom
wpbonelli:option-columns

Conversation

@wpbonelli

Copy link
Copy Markdown
Member

Some fields are valid only when another option is set, e.g. EVT's petm0 with SURF_RATE_SPECIFIED. The DFNs now have a when attribute (MODFLOW-ORG/modflow-devtools#395) indicating this. Use it

Boundnames move onto the same mechanism after #470

wpbonelli and others added 8 commits October 14, 2026 20:36
EVT's petm0 is read only with SURF_RATE_SPECIFIED, and then always. The
row layout took it if a token was left for it, so with BOUNDNAMES set a
row leaving out its boundname lost its petm0 to the boundname. Codegen
now marks petm0 with its option, the row context carries the options a
package has set, and the layout reads a gated column by its option. A
Python row with petm0 sets the option, as one with a boundname sets
BOUNDNAMES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MF6 tries an observation's id as a cell before a boundname, so an id
naming boundname 5 is node 5 on a DISU grid, or an error on another.
Writing a package now warns if one of its observations does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pins MODFLOW-ORG/modflow-devtools#395 (9a1662ef), which adds the when
attribute codegen will read in place of the _OPTION_COLUMNS table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops codegen's _OPTION_COLUMNS table for the when attribute
modflow-devtools now migrates (EVT's petm0, by surf_rate_specified).
Regenerating gives no diff. Boundname keeps its own handling for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Renames the option field metadata to when, after the DFN attribute, and
stores optional unchanged: EVT's petm0 is now when=surf_rate_specified,
not optional. Whether a column may be missing from a row is optional or
when, worked out in one place (item._may_be_absent), and codegen gives it
a None default on the same test. A column whose option is on is required
unless it's optional, rather than always, so boundname can carry
when=boundnames later and still be left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The DFN's when isn't only for list columns, and "options" meant three
things: option_columns is now conditional_fields, RowContext.options
(the options that are on) is RowContext.enabled, _layout's inner
options() (the ways a slot can take values) is fits(), and by_option is
conditional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added this to the MVP milestone Oct 15, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review October 15, 2026 16:45
@wpbonelli
wpbonelli merged commit 40c6074 into modflowpy:develop Oct 15, 2026
17 checks passed
@wpbonelli
wpbonelli deleted the option-columns branch October 15, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant