Skip to content

Commit

Permalink
Merge branch 'main' into sc_voltage_results_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLt authored Sep 22, 2023
2 parents d8efa29 + 3029ed8 commit 7ee4bdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpp/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ PYBIND11_MODULE(_pypowsybl, m) {
.value("CONVERGED", pypowsybl::LoadFlowComponentStatus::CONVERGED, "The loadflow has converged.")
.value("FAILED", pypowsybl::LoadFlowComponentStatus::FAILED, "The loadflow has failed.")
.value("MAX_ITERATION_REACHED", pypowsybl::LoadFlowComponentStatus::MAX_ITERATION_REACHED, "The loadflow has reached its maximum iterations count.")
.value("SOLVER_FAILED", pypowsybl::LoadFlowComponentStatus::SOLVER_FAILED, "The loadflow numerical solver has failed.");

.value("SOLVER_FAILED", pypowsybl::LoadFlowComponentStatus::SOLVER_FAILED, "The loadflow numerical solver has failed.")
.def("__bool__", [](const pypowsybl::LoadFlowComponentStatus& status) {
return status == pypowsybl::LoadFlowComponentStatus::CONVERGED;
});

py::enum_<pypowsybl::PostContingencyComputationStatus>(m, "PostContingencyComputationStatus", "Loadflow status for one connected component after contingency for security analysis.")
.value("CONVERGED", pypowsybl::PostContingencyComputationStatus::CONVERGED, "The loadflow has converged.")
.value("FAILED", pypowsybl::PostContingencyComputationStatus::FAILED, "The loadflow has failed.")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_loadflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,9 @@ def test_run_lf_with_report():
pp.loadflow.run_ac(n2, reporter=reporter)
report3 = str(reporter)
assert len(report3) > len(report2)


def test_result_status_as_bool():
n = pp.network.create_ieee14()
r = pp.loadflow.run_ac(n)
assert r[0].status

0 comments on commit 7ee4bdc

Please sign in to comment.