Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
471 changes: 233 additions & 238 deletions autotest/dfns/__snapshots__/v2.0.0.dev2/gwf-lak.json

Large diffs are not rendered by default.

87 changes: 42 additions & 45 deletions autotest/dfns/__snapshots__/v2.0.0.dev2/gwf-lak.toml

Large diffs are not rendered by default.

577 changes: 284 additions & 293 deletions autotest/dfns/__snapshots__/v2.0.0.dev2/gwf-lak.yaml

Large diffs are not rendered by default.

471 changes: 233 additions & 238 deletions autotest/dfns/__snapshots__/v2.0.0.dev3/gwf-lak.json

Large diffs are not rendered by default.

87 changes: 42 additions & 45 deletions autotest/dfns/__snapshots__/v2.0.0.dev3/gwf-lak.toml

Large diffs are not rendered by default.

577 changes: 284 additions & 293 deletions autotest/dfns/__snapshots__/v2.0.0.dev3/gwf-lak.yaml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions autotest/dfns/test_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@ def test_migrate_lak_connectiondata_shape(dfn_dir, tmp_path, v1_shape):
assert component.dims["nlakeconn"].value == "sum(packagedata.nlakeconn)"


@pytest.mark.parametrize(
("name", "setting"), [("gwf-lak", "laksetting"), ("prt-prp", "releasesetting")]
)
def test_migrate_period_union_element(dfn_dir, name, setting):
"""A period list of only a union is a list of the union: PRP's, and LAK's
once its lake or outlet number moves into the arms."""
component = _migrate_dev3(dfn_dir, name)
item = component.blocks["period"].fields["perioddata"].item
assert isinstance(item, v2.Union) and item.name == setting
if name == "gwf-lak":
assert item.arms["stage"].fields["lakeno"].fk == "packagedata.ifno"
assert item.arms["rate"].fields["outletno"].fk == "outlets.outletno"


def test_migrate_auxiliary_stays_self_sizing(dfn_dir):
component = _migrate_dev3(dfn_dir, "gwf-chd")
assert component.blocks["options"].fields["auxiliary"].shape == []
Expand Down
4 changes: 3 additions & 1 deletion docs/md/sfr-lak-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ explicitly in `_fix_lak_relations` (`migrate_to_v2_0_0_dev2.py`):
copy, pushed inside each `laksetting` union arm with a name and `fk`
appropriate to that arm's category: `lakeno` / `fk: packagedata.ifno` for
the 8 lake-setting arms, `outletno` / `fk: outlets.outletno` for the 5
outlet-setting arms. (`outlets.outletno` is also newly marked `pk`, since
outlet-setting arms. That leaves `laksetting` the only field of the period
list's element, so the element becomes the union itself, as PRP's
`releasesetting` is. (`outlets.outletno` is also newly marked `pk`, since
nothing else previously pointed at it — needed for the new `outletno` fk to
resolve.)

Expand Down
15 changes: 8 additions & 7 deletions modflow_devtools/dfns/migrate_to_v2_0_0_dev2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,8 @@ def _fix_lak_relations(name: str, blocks: dict[str, v2.Block]) -> dict[str, v2.B
fields nested inside the corresponding `laksetting` union arms, each
carrying a correct, non-conditional `fk` (a single `fk` on the shared
`number` field can't be correct for both arm categories at once, since
the target block depends on which arm is present).
the target block depends on which arm is present). The period list's
element is then `laksetting` itself.
- Marks `outlets.outletno` as `pk` (the new `outletno` fk needs one).
- Marks `outlets.lakein`/`outlets.lakeout` as `fk: packagedata.ifno` —
unambiguous, but named differently from `ifno` so the general
Expand Down Expand Up @@ -1381,12 +1382,12 @@ def _retarget(
new_arms[arm_name] = arm

new_setting = setting_field.model_copy(update={"arms": new_arms})
new_item = item.model_copy(
update={
"fields": {fn: f for fn, f in item.fields.items() if fn != "number"}
| {"laksetting": new_setting}
}
)
fields = {fn: f for fn, f in item.fields.items() if fn != "number"} | {
"laksetting": new_setting
}
# With `number` in its arms, a record of only the union is the union: the
# list's element is the union itself, as PRP's `releasesetting` is.
new_item = new_setting if len(fields) == 1 else item.model_copy(update={"fields": fields})
new_perioddata = perioddata.model_copy(update={"item": new_item})
new_period = period.model_copy(
update={"fields": {**period.fields, "perioddata": new_perioddata}}
Expand Down
Loading