Skip to content

Conversation

@RobbieKiwi
Copy link
Contributor

@RobbieKiwi RobbieKiwi commented Nov 1, 2025

Closes #513
Closes #517

Changes proposed in this Pull Request

Add LinearExpression.from_constant
Now constraints just containing constants cannot be created

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.

@RobbieKiwi
Copy link
Contributor Author

I notice an issue that if there is a linear expression that only contains constants, some of the methods seem a bit strange.
For example if I do expr.to_polars() I get a pl.DataFrame with 0 rows

Copy link
Collaborator

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice and clean

@FabianHofmann
Copy link
Collaborator

I notice an issue that if there is a linear expression that only contains constants, some of the methods seem a bit strange. For example if I do expr.to_polars() I get a pl.DataFrame with 0 rows

ah right, I haven't thought about that. I guess we would need to fix that one in particular. would you be able to do so? (could also be a follow up)

@RobbieKiwi RobbieKiwi force-pushed the feature/add-const-expression branch from 4aebe03 to 1eddef9 Compare December 7, 2025 11:27
@RobbieKiwi
Copy link
Contributor Author

@FabianHofmann I made some fixes to the "to_polars" thing for Linear and Quadratic expressions that are constant
I can't merge because of some weird PyPSA-Eur test

@RobbieKiwi RobbieKiwi mentioned this pull request Dec 7, 2025
2 tasks
@RobbieKiwi
Copy link
Contributor Author

@FabianHofmann ready to merge if you are happy with it

@FabianHofmann
Copy link
Collaborator

@RobbieKiwi I took the freedom to push some fixes. would merge when the ci is through

@FabianHofmann FabianHofmann merged commit be4657d into PyPSA:master Dec 16, 2025
20 checks passed
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.

Infeasible constraint ignored Easy way to create constant expression

2 participants