Skip to content

test: dense/sparse store conformance suite and assert_equivalent (#1019 step 1) - #1050

Merged
FabianHofmann merged 2 commits into
masterfrom
store/1-conformance
Oct 23, 2026
Merged

FabianHofmann merged 2 commits into
masterfrom
store/1-conformance

Conversation

@FabianHofmann

@FabianHofmann FabianHofmann commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

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 Store protocol 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 .data on a sparse expression, so it cannot densify what it checks.
  • backend fixture in test/conftest.py parametrised over Model(sparse=False) and Model(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 with assert_equivalent. Negative tests show assert_equivalent fails on differing coefficients, constants, null masks and auxiliary coordinates.
  • no_densify moved from test/test_csr.py into the new module.

Where the plan table in #1044 did not match master, the suite encodes master: sum with a non-grid dim raises on both backends, loc and diff stay sparse, some fallbacks use the generic .data read 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

  • AI-generated content is marked (see AGENTS.md).
  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Next layer: #1051 (step 2a).

…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.
@codspeed

codspeed Bot commented Oct 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 181 untouched benchmarks
⏩ 181 skipped benchmarks1


Comparing store/1-conformance (6e6051e) with master (20384ee)

Open in CodSpeed

Footnotes

  1. 181 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@FabianHofmann
FabianHofmann marked this pull request as ready for review October 23, 2026 05:48
@FabianHofmann
FabianHofmann merged commit a301216 into master Oct 23, 2026
22 checks passed
@FabianHofmann
FabianHofmann deleted the store/1-conformance branch October 23, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conformance suite over dense and sparse backends with a layout-free assert_equivalent

1 participant