PyPSA / linopy

Linear optimization with N-D labeled arrays in Python
https://linopy.readthedocs.io
MIT License
155 stars 43 forks source link

allow removing multiple constraints at once #211

Closed Irieo closed 7 months ago

Irieo commented 7 months ago

Make possible to pass a list into remove_constraints() to remove multiple constraints at once. Keeps old functionality, i.e. it is still possible to pass constraint name as a string. Adds logging, so user can see what constraints are removed.

to remove all constraints: n.model.remove_constraints(list(n.model.constraints))

to remove a single constraint: n.model.remove_constraints(['Bus-nodal_balance']) or n.model.remove_constraints('Bus-nodal_balance')

closes https://github.com/PyPSA/linopy/issues/210

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (930ceae) 89.26% compared to head (148a545) 89.28%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #211 +/- ## ========================================== + Coverage 89.26% 89.28% +0.01% ========================================== Files 15 15 Lines 3354 3359 +5 Branches 771 773 +2 ========================================== + Hits 2994 2999 +5 Misses 248 248 Partials 112 112 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

FabianHofmann commented 7 months ago

Are you fine, if I set the logging from info to debug?

Irieo commented 7 months ago

Are you fine, if I set the logging from info to debug?

sure!