Repository navigation
test: dense/sparse store conformance suite and assert_equivalent (#1019 step 1) - #1050
Merged
Merged
Conversation
…1044) Add a backend fixture, assert_equivalent in linopy.testing and a table-driven test listing every operation and argument case with its expected kept-or-densify outcome on both backends.
Merging this PR will not alter performance
Comparing Footnotes
|
5 tasks done
FabianHofmann
marked this pull request as ready for review
October 23, 2026 05:48
5 tasks done
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.
Stack 1/3 of #1019; #1020 (2a, 2b) follow on top of this branch.
Closes #1044.
Changes proposed in this Pull Request
Step 1 of the store refactoring plan in #1019: a conformance suite that pins what the dense and the sparse (CSR) backing must agree on before the
Storeprotocol lands.linopy.testing.assert_equivalent(a, b): two linear expressions are equivalent when they share the grid including auxiliary coordinates, the same null mask, the same constants and the same per-cell term matrix after zero pruning and duplicate summing. It never reads.dataon a sparse expression, so it cannot densify what it checks.backendfixture intest/conftest.pyparametrised overModel(sparse=False)andModel(sparse=True).test/test_store_conformance.py: one table of (operation, argument case, expected) rows derived from the current CSR overrides. "Kept" rows run the sparse side under a no-densify guard and assert the result stays sparse; fallback rows assert exactly one densify notice with the named reason. Both backends are compared withassert_equivalent. Negative tests showassert_equivalentfails on differing coefficients, constants, null masks and auxiliary coordinates.no_densifymoved fromtest/test_csr.pyinto the new module.Where the plan table in #1044 did not match master, the suite encodes master:
sumwith a non-grid dim raises on both backends,locanddiffstay sparse, some fallbacks use the generic.dataread reason. One strict xfail records that a dense constraint built from==keeps==while the sparse one normalises to=.The receiver-stays-sparse assertion after a fallback is deliberately not asserted yet; today the receiver is converted in place, PR 2b changes that and adds the assertion.
Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.Next layer: #1051 (step 2a).