Skip to content

Make LinearExpression multiplication with constant containing subset of dimensions consistent with Variable behaviour#571

Open
RobbieKiwi wants to merge 1 commit intoPyPSA:masterfrom
RobbieKiwi:feature/consistent-multiplication
Open

Make LinearExpression multiplication with constant containing subset of dimensions consistent with Variable behaviour#571
RobbieKiwi wants to merge 1 commit intoPyPSA:masterfrom
RobbieKiwi:feature/consistent-multiplication

Conversation

@RobbieKiwi
Copy link
Contributor

@RobbieKiwi RobbieKiwi commented Feb 6, 2026

Closes #569 #570

Changes proposed in this Pull Request

Now LinearExpression behaves the same way as Variable when multiplying with a constant containing a susbet of dimensions. Still it is not consistent with addition.

Action Coords Missing coord behaviour
Addition Same coords add 0
Variable Multiplication Same coords nan
Expression Multiplication Same coords nan

For addition, when a coord is mising we just add 0 (I.e do nothing at that coord)
Perhaps the equivalent for multiplication would be to multiply by 1 (also do nothing) rather than fill with nan?

Checklist

  • 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.

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.

Inconsistent multiplication behavior: Variable vs LinearExpression with subset coordinates

1 participant