Repository navigation
fix(semantics): close gaps and false positives in legacy v1 warnings - #1026
Merged
Merged
Conversation
Build cost — v1 vs legacyv1 build peak & time relative to legacy, on this commit — not a comparison against master (that is CodSpeed).
Full table (time + peak, mean)📊 Interactive plots + CSV: download the semantics-report-v1-vs-legacy artifact from this run. Report-only · not a gate · refreshed on every push · obsolete once legacy is dropped. |
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Changes proposed in this Pull Request
An audit of the legacy → v1 semantics warnings found operations whose result changes under v1 without any
LinopySemanticsWarning, plus some warnings that fire although results agree. This PR closes those gaps so that, under legacy, each diverging operation warns once and points at user code.Missing warnings (now warn)
x.diff("t") >= 0,expr.shift(t=1) + y,expr.where(mask) + 5,expr.reindex(...) + 1, quadratic(x*y).where(mask) + 1. New helperwarn_legacy_absenceinsemantics.py, used in merge and the legacy constant paths..divwith a reindexingjoin=that creates divisor positions (legacy fills 1, v1inf).x(t=0,1,2) * y(t=0,1)): the coordinate check now runs beforebroadcast_like. Under v1 this raises, like other exact-join mismatches. Legacy also no longer writes NaN floats into the factor labels; labels stay integer with-1.False positives / noise removed
x.where(mask).sum()and.groupby(...).sum()no longer warn (identical results).(1*x).le(rhs_superset, join="left")no longer warns.(1*x) <= rhs_subsetwarns once instead of twice (spurious "NaN in constant" from linopy's own reindex).stacklevels removed from the legacy warning paths, so warnings point at user code.Corrected messages
join=hint (mulrejectsjoin=for expr × expr).to_constraintwith explicitjoin=: legacy ignores the join, v1 applies it (was "v1 raises").Variable * constant: aligns by label (was "positional").x.where(mask) <= 3keeps warning: legacy keeps a labelled empty row, v1 drops it, so constraint labels andnconsdiffer.Legacy results are unchanged apart from the integer-label fix for quadratic products. The only v1 behaviour change is the new raise for mismatched quadratic factors.
Test runs
test/test_legacy_violations.py: 412 passed, 234 skipped (new parametrized classTestLegacyWarnsAtDivergence)test/remote, Xpress and non-HiGHS optimization: 5304 passed, 1096 skippedtest_optimizationwith HiGHS: 539 passedChecklist
doc.doc/release_notes.rstof the upcoming release is included.