feat(language): a quantity defined by cases may mix a constant, a parameter and a variable across its regions - #1464
Merged
Merged
Conversation
FBumann
force-pushed
the
build/pin-alpha-51
branch
from
August 31, 2026 12:23
f00f883 to
0112b9d
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
…ach region carries only where it applies math-spec v0.0.0-alpha.49 -> v0.0.0-alpha.51, whose `cases:` block adds the one node that carries a mask in a value position. Both lanes build it by keeping each region to its own mask and adding the results, the language having proved the regions disjoint and total before any data binds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TZbCoSM1Ah7YWg6K4Ps5sU
FBumann
force-pushed
the
build/pin-alpha-51
branch
from
August 31, 2026 12:30
0112b9d to
22655b1
Compare
… names no dimension, and a divisor inside one is asked only there Three defects found reviewing the cases: cut, each reproduced on both lanes before it was fixed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kpKM4mnqRDNaXYweFvLmH
…e issue that owns it Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kpKM4mnqRDNaXYweFvLmH
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.
Note
The following content was generated by AI.
math-spec
v0.0.0-alpha.49→v0.0.0-alpha.51, whosecases:block lets a model state onequantity by region. Both engines build it: each region is kept to its own mask and the
results added, the language having proved the regions disjoint and total before any data
binds, so neither ranks them and neither needs a tie-break.
A region reaches only the coordinates it claims. Its data is owed only there — a parameter
standing for one region is not asked to cover the frame, and a divisor is asked the same
narrowed question — and its absence stays inside it, so a region empty where it does not
apply cannot unmake a row another region covers. A
when:that names no dimension is ascalar switch and is held to the same two rules.
Casesis the first node carrying a mask in a value position, and the plan table indocs/about/architecture.mdgains its row;ARCHITECTURErule 1 is corrected, a casedexpression being the one named expression that is not substituted away before dispatch.
The PyPSA ladder is untouched here — the corpus adopting
cases:ismath-spec#292, and the committed
certificate is byte-identical after a full parity re-run.
Mutation table
Five through
tools/mutate.py --tests tests/test_cases.py; four are changed lines ratherthan deleted ones, which the tool cannot express, so they were taken by hand with its three
precautions — tree committed first, restored with
git checkout --,__pycache__droppedon both sides, tree asserted clean at the end (it was).
compiler.py)compiler.py)compiler.py)compiler.py)engine.py)builder.py)coverage.py)coverage.py)coverage.py)Each region is read, and its own data decides the answer
Objective agreement alone would pass on an expression that collapsed to one region, so each
case varies the data one region reads:
A hole a
sumor a divide has consumed is still unreported — #1465A hole on a constant side is reported by both engines where the piece is joined at the row
key. It is not reported by the relational engine once an aggregation has summed it away:
the piece is summed per coordinate before the check looks, and polars reads a null sum as
zero.
No
cases:appears in that repro — it predates this change and is filed as#1465.
test_a_hole_in_a_divisor_inside_its_region_is_still_refusedtherefore asserts the eagerengine alone and names the issue for why.
Verified
pixi run lint/format-checkclean;pyrefly0 errors, both legs.pixi run test— 3464 passed, 251 skipped, 94 failed, every failurexpress: theexpired local licence, matched as
tests/test_xpress_sink.pyor a[…xpress…]parameterid rather than by the substring, since
test_..._every_expression_nodecontainsxpress.PyPSA parityall 15 rungs MATCH with the certificate unchanged;tools.ladder --checkclean.
pixi run test-bench— it refuses a loaded box and nobench/file changed.Deliberately not done
examples/model gainscases:— the construct is covered bytests/test_cases.py; a gallery model would pull in a page, the catalogue andreferences.json.cases:insidemacros:is not supported, which is the language's own restriction.