fix: filter solution/dual arrays to own model components in extra outputs#246
Merged
aoustry merged 2 commits intoJul 9, 2026
Conversation
…puts When multiple models coexist in a problem, linopy's merged solution/dual Datasets outer-join their component coordinates, padding each model's variable and constraint-dual arrays with NaN entries for other models' components. minimum()/maximum() in extra outputs use xr.where, which requires aligned coordinates and breaks on this padding. Filter var_solution_arrays and constraint_dual_arrays back down to each model's own components in simulation_table.py, mirroring the existing guard in _collect_vars_outputs. Extends test_extra_output_min_on_variable with a second coexisting model to reproduce and guard against the issue, per Juliette Gerbaux's review on #240.
aoustry
changed the base branch from
main
to
claude/fix-extra-output-comparison-237
July 9, 2026 13:55
aoustry
commented
Jul 9, 2026
aoustry
merged commit Jul 9, 2026
25fab1c
into
claude/fix-extra-output-comparison-237
2 checks passed
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.
Process ID
[GP-02] Fix
minimum()/maximum()in extra outputs when multiple models coexistProcess: Follow-up to #240 / #237, addressing Juliette Gerbaux's review
Description
PR #240 added support for comparisons and
minimum()/maximum()in post-solveextra-output expressions. Juliette flagged a bug during review: when multiple
models coexist in the same problem, linopy's merged
solution/dualDatasetsouter-join their
componentcoordinates, so a model's own variable/dual arraysget padded with NaN entries for other models' components.
minimum()/maximum()(implemented via
xr.where, which requires exact coordinate alignment) thenraise an
AlignmentErrorinstead of evaluating.This PR filters
var_solution_arraysandconstraint_dual_arraysback down toeach model's own components in
simulation_table.py::_collect_extra_outputs/_collect_constraint_duals, mirroring the guard already present in the siblingmethod
_collect_vars_outputs.test_extra_output_min_on_variableis extendedwith a second, unrelated model/component (
OTHER_MODEL/comp_2) to reproducethe outer-join scenario and guard against regressions, per Juliette's inline
suggestions on #240.
Verified the new test fails with
xarray.structure.alignment.AlignmentErrorbefore this fix and passes after.
Impact Analysis
simulation/simulation_table.py— only affects extra-output evaluation when astudy has multiple models with disjoint component sets; solver output values
for existing single-model tests are unchanged.
Checklist
pytest)mypy)black,isort)pyproject.tomlversion bumped if applicableAGENTS.mdreviewed for impact and updated if neededGenerated by Claude Code