Skip to content

Commit

Permalink
contingency: add option to raise errors if a contingency leads to an …
Browse files Browse the repository at this point in the history
…error instead of skipping it
  • Loading branch information
rbolgaryn committed Jan 10, 2024
1 parent b0ca597 commit 28bdec5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pandapower/contingency/contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def run_contingency(net, nminus1_cases, pf_options=None, pf_options_nminus1=None
"""
# set up the dict for results and relevant variables
# ".get" in case the options have been set in pp.set_user_pf_options:
raise_errors = kwargs.get("raise_errors", False)
if "recycle" in kwargs: kwargs["recycle"] = False # so that we can be sure it doesn't happen
if pf_options is None: pf_options = net.user_pf_options.get("pf_options", net.user_pf_options)
if pf_options_nminus1 is None: pf_options_nminus1 = net.user_pf_options.get("pf_options_nminus1",
Expand Down Expand Up @@ -104,6 +105,8 @@ def run_contingency(net, nminus1_cases, pf_options=None, pf_options_nminus1=None
cause_element=element, cause_index=i)
except Exception as err:
logger.error(f"{element} {i} causes {err}")
if raise_errors:
raise err

Check warning on line 109 in pandapower/contingency/contingency.py

View check run for this annotation

Codecov / codecov/patch

pandapower/contingency/contingency.py#L108-L109

Added lines #L108 - L109 were not covered by tests
finally:
net[element].at[i, 'in_service'] = True

Expand Down

0 comments on commit 28bdec5

Please sign in to comment.