Skip to content

ensure period in block order is last#309

Merged
mjreno merged 4 commits intoMODFLOW-ORG:developfrom
mjreno:block_sort_key
Apr 27, 2026
Merged

ensure period in block order is last#309
mjreno merged 4 commits intoMODFLOW-ORG:developfrom
mjreno:block_sort_key

Conversation

@mjreno
Copy link
Copy Markdown
Contributor

@mjreno mjreno commented Apr 24, 2026

No description provided.

return 4
else:
return 5
return 3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the general rule is: options, dimensions, grid, everything else, period blocks?

the packagedata condition above could go away then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should always reflect dfn order, maybe so?

block_name: {field["name"]: FieldV1.from_dict(field) for field in block}
for block_name, block in groupby(fields.values(), lambda field: field["block"])
for block_name, block in groupby(
fields.values(multi=True), lambda field: field["block"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, nice catch.

k, _ = item
if k == "options":
return 0
elif k == "dimensions":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does dimensions not need to come before grid data?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This routine sorts dfn block order- elsewhere convention is the rule. Seems like enumerating all possible blocks is the right way if we want to enforce it here or if not remove?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not just convention, it's block order defined in dfn as schema.

Copy link
Copy Markdown
Member

@wpbonelli wpbonelli Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah only implicitly defined, right? and we are making it explicit with this routine. so if there is a rule to enforce, here is the place, but that's what I don't know: does the dimensions block need to come before griddata like it does before period blocks?

or do we just take the order defined in the DFN as the rule? in which case we should make that explicit somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes dimensions always immediately follow options when it is defined.

That's what I was trying to get at- this really fits more cleanly in the schema and it is there already just not as explicit as we would like. Maybe we can talk about this before this PR goes in.

@mjreno mjreno changed the title maintain dfn block order ensure period in block order is last Apr 27, 2026
@mjreno mjreno merged commit 06e14c2 into MODFLOW-ORG:develop Apr 27, 2026
56 of 60 checks passed
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