Repository navigation
Fix pandapower contingency analysis and Egret OPF on unrated branches - #137
Merged
Merged
Conversation
pandapowerNet has no deepcopy() method, so run_contingency_analysis failed on every call with "'pandapowerNet' instance has no attribute 'deepcopy'". Closes #127 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rror MATPOWER marks an unlimited branch with rateA = 0. powerio leaves Egret's rating keys out for those branches, and Egret's OPF models index branches[k]['rating_long_term'] directly, so solve_dc_opf failed with KeyError: 'rating_long_term' on case5, case14 and similar cases. The solver tools now fill a missing rating_long_term / rating_short_term / rating_emergency with None before solving. That is what Egret's own MATPOWER parser writes, and its models treat None as no thermal limit. The new test skips in CI, which doesn't install the egret extra. Closes #128 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes two bugs reported by @ibrahim-siali. Both reproduced on main before the fix.
#127: pandapower
run_contingency_analysisalways failed. It callednet.deepcopy(), butpandapowerNethas no such method, so every call returned'pandapowerNet' instance has no attribute 'deepcopy'. It now usescopy.deepcopy.#128: Egret
solve_dc_opffailed on branches with no rating. MATPOWER marks an unlimited branch with rateA = 0. powerio leaves Egret's rating keys out for those branches (0.11.5 omits them; the issue sawnullon 0.11.4). Egret's OPF models readbranches[k]['rating_long_term']directly, so the solve raisedKeyError: 'rating_long_term'. The three solver tools now read cases through_read_model_data, which fills a missingrating_long_term/rating_short_term/rating_emergencywithNone. Egret's own MATPOWER parser writesNonefor these branches, and its models treat it as no thermal limit, so the case solves with those branches unconstrained.Testing
tests/test_pandapower_contingency.py: N-1 on case14. On main it fails with the issue's exact error. With the fix it passes, and the stored network is left unchanged.tests/test_egret_unrated_branches.py: IEEE 14-bus with alternate branches unrated, loaded withload_model_from_anyand solved withsolve_dc_opf(HiGHS). On main it fails with'rating_long_term'. With the fix it solves, and the 10 unrated branches come back unlimited. This test skips in CI, which doesn't install theegretextra; I ran it locally with gridx-egret 0.6.2.Closes #127
Closes #128
🤖 Generated with Claude Code