test: use public API in assertions instead of internal .data#760
Merged
Conversation
Switch test assertions from the internal `.data` accessor to the public `.coords`/`.indexes`/`.sizes` properties (thin pass-throughs to `.data`, so behaviour is identical). Genuine `_factor` dimension checks in test_quadratic_expression stay on the internal array, but now use `.vars.sizes[FACTOR_DIM]` — the `_factor` helper dim lives on `vars`, not `coeffs`, and isn't surfaced by any public accessor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
FabianHofmann
approved these changes
Jun 7, 2026
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 is meant to harden the "public" vs internal api a bit more. It will allow to potentially improve/change the datamodel of linopy if needed in certain places, while being fully backwards compatible.
Note
The following content was generated by AI.
Summary
Switches test assertions from the internal
.dataaccessor to the public.coords/.indexes/.sizesproperties. These properties are thin pass-throughs to.data, so the assertions exercise identical data — this is a readability/encapsulation cleanup that stops tests from reaching through.data.test_variable.py—var.sizes,var.coords[...](andbase.coordswhen seedingadd_variables)test_linear_expression.py—result.indexes[...], plus coord-building helpers and the HELPER_DIMS-cleanliness checktest_constraint.py—con.sizes[...]and the HELPER_DIMS intersection checkGenuine helper-dim checks
_factorsize checks intest_quadratic_expression.pystay on the internal array, since no public accessor surfaces that helper dim. They now use.vars.sizes[FACTOR_DIM]— the_factordim lives onvars, notcoeffs(coeffsonly carries_term). The existing.coeffs.dims/.const.dimsfactor checks are left as-is.The
HELPER_DIMS-intersection assertions deliberately stay on.coords(not.coord_dims):.coordsis an unfiltered pass-through, so the check remains real, whereas.coord_dimsfilters helper dims and would make the assertion a tautology.Testing
pytest test/test_variable.py test/test_linear_expression.py test/test_constraint.py test/test_quadratic_expression.py— 504 passed.