feat: add IN [...] coord filter to sum_over#69
Merged
jc-macdonald merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
pearsonca
approved these changes
Apr 23, 2026
Member
pearsonca
left a comment
There was a problem hiding this comment.
Minor notes for future work
| ) | ||
| _SUM_OVER_RE = re.compile( | ||
| r"sum_over\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_]*)\s*,\s*(.*?)\)", | ||
| r"sum_over\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_]*)" |
Member
There was a problem hiding this comment.
note for future work: desire to avoid needing regular expressions. I think the ideal here is figuring out how to rely on the equation / symbol parsing libs.
Member
There was a problem hiding this comment.
what's error like for, say, a missing close ]? we should figure out (perhaps not in this PR) how to handle that sort of problem gracefully and with useful feedback.
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.
This pull request adds support for filtering the coordinates included in
sum_overexpressions using an optionalIN [...]clause. This allows users to specify a subset of axis coordinates to sum over, rather than always summing over all coordinates. The implementation includes robust error checking for invalid, empty, unknown, or duplicate coordinates in the filter. Comprehensive tests have been added to ensure correct behavior and error handling.Enhancements to
sum_oversyntax:_SUM_OVER_REregular expression insrc/op_system/specs.pyto support an optionalIN [...]filter for specifying a subset of coordinates to sum over._apply_coord_filterhelper function to validate and apply the coordinate filter, raising errors for empty, unknown, or duplicate coordinates._expand_sum_overlogic to use the filtered coordinate list when expanding sums, ensuring only the specified coordinates are included.Testing and validation:
tests/op_system/test_op_system_specs.pyto verify correct expansion and error handling for the newsum_over IN [...]syntax, including cases for valid filters, empty filters, unknown coordinates, and duplicates.tests/op_system/test_op_system_compile.pyto ensure that the filtered sum compiles and evaluates correctly.