Skip to content

feat(dfns): support shape evaluation - #383

Merged
wpbonelli merged 6 commits into
MODFLOW-ORG:developfrom
wpbonelli:parse-shape
Oct 6, 2026
Merged

wpbonelli merged 6 commits into
MODFLOW-ORG:developfrom
wpbonelli:parse-shape

Conversation

@wpbonelli

@wpbonelli wpbonelli commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Dim expressions and shape expressions are small grammars that devtools validates, but up to now consumers (e.g. flopy4) have had to re-parse and evaluate them. Expose functions to do this

  • dim_value: evaluates a dim or shape expression
  • dim_input: evaluate in reverse: rather than plug inputs in, find the input to plug in so the expression gives the data's length, i.e. the input to sync

wpbonelli and others added 3 commits October 6, 2026 06:12
Add ShapeRef, parse_shape_element and resolve_shape_ref, and rebuild the
Array/List shape validators on them so there's one implementation of the
shape grammar. Also export split_bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_shape_element takes the enclosing record and returns "sibling" for
an Integer subfield of it; loading rejects a name that's both a dim and a
sibling, so no resolver is needed. Drop resolve_shape_ref and fold the
Array/List shape validators into one check.

Add evaluate_dim, which evaluates a dim value expression given the dim
expressions and an input lookup. Require an input dim's bare field name to
be the dim's own name, and document input vs derived dims in the spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Consumers evaluate shapes rather than classify them: evaluate_dim now
takes any dimension expression (a dim, or a shape expression without its
bound), with a select callback for row-level lookups. The shape parser and
ShapeRef become private, used only by validation.

Loading now requires an inline array whose size varies by row (a sibling
or lookup shape) to be the rightmost field in its record, as for a
self-sizing array, so consumers needn't check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added this to the 1.10.0 milestone Oct 6, 2026
Given the extent data has, solve_dim returns the unset input that
determines it and its value (nseg-1 with 3 values gives nseg=4), so a
consumer can fill in counts the user left out. Only names, through dims,
and +/- of known values are undone; anything else gives None, and the
data can only be checked. Shares the expression walk with evaluate_dim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added the enhancement New feature or request label Oct 6, 2026
wpbonelli and others added 2 commits October 6, 2026 07:33
The nouns say what each returns (a dim's value, or the input a length
determines), where the verbs read as near-synonyms. dim_input's target is
the keyword-only `length`, and the spec says "length" for the size along
one axis (was "extent"). dims and lookup are optional: no dims, nothing
set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli
wpbonelli marked this pull request as ready for review October 6, 2026 14:51
@wpbonelli
wpbonelli merged commit 805dc6f into MODFLOW-ORG:develop Oct 6, 2026
16 checks passed
@wpbonelli
wpbonelli deleted the parse-shape branch October 6, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant