Repository navigation
feat(dfns): support shape evaluation - #383
Merged
Merged
Conversation
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>
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 expressiondim_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