Skip to content

Commit

Permalink
Apply pre-commmit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayapreethi authored and actions-user committed Apr 29, 2024
1 parent 227119b commit 2bc9c7f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
114 changes: 57 additions & 57 deletions interfaces/python/exago_python_tcopflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,71 +29,71 @@ class TCOPFLOW_wrapper {
void init_exago_tcopflow(pybind11::module &m) {

pybind11::class_<TCOPFLOW_wrapper>(m, "TCOPFLOW")
.def(pybind11::init())
.def("set_network_data",
[](TCOPFLOW_wrapper &w, std::string filename) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetNetworkData(w.tcopf, filename.c_str());
ExaGOCheckError(ierr);
})
.def("set_solver", [](TCOPFLOW_wrapper &w, std::string solver) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetSolver(w.tcopf, solver.c_str());
ExaGOCheckError(ierr);
})
.def("set_tolerance",
.def(pybind11::init())
.def("set_network_data",
[](TCOPFLOW_wrapper &w, std::string filename) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetNetworkData(w.tcopf, filename.c_str());
ExaGOCheckError(ierr);
})
.def("set_solver",
[](TCOPFLOW_wrapper &w, std::string solver) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetSolver(w.tcopf, solver.c_str());
ExaGOCheckError(ierr);
})
.def("set_tolerance",
[](TCOPFLOW_wrapper &w, double tol) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetTolerance(w.tcopf, tol);
ExaGOCheckError(ierr);
})
.def("setup", [](TCOPFLOW_wrapper &w) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetUp(w.tcopf);
ExaGOCheckError(ierr);
})
.def("solve",
.def("setup",
[](TCOPFLOW_wrapper &w) {
PetscErrorCode ierr;
ierr = TCOPFLOWSetUp(w.tcopf);
ExaGOCheckError(ierr);
})
.def("solve",
[](TCOPFLOW_wrapper &w) {
PetscErrorCode ierr;
ierr = TCOPFLOWSolve(w.tcopf);
ExaGOCheckError(ierr);
})

.def("get_convergence_status",
[](TCOPFLOW_wrapper &w) -> bool {
PetscErrorCode ierr;
PetscBool flag;
ierr = TCOPFLOWGetConvergenceStatus(w.tcopf, &flag);
ExaGOCheckError(ierr);
return flag;
})
.def("get_objective",
[](TCOPFLOW_wrapper &w) -> double {
PetscErrorCode ierr;
double obj;
ierr = TCOPFLOWGetObjective(w.tcopf, &obj);
ExaGOCheckError(ierr);
return obj;
})
.def("get_num_iterations",
[](TCOPFLOW_wrapper &w) -> int {
PetscErrorCode ierr;
PetscInt n;
ierr = TCOPFLOWGetNumIterations(w.tcopf, &n);
ExaGOCheckError(ierr);
return n;
});
/*.def("save_solution",
[](TCOPFLOW_wrapper &w, OutputFormat fmt, std::string outfile) {
PetscErrorCode ierr;
ierr = TCOPFLOWSaveSolution(w.tcopf, fmt, outfile.c_str());
ExaGOCheckError(ierr);
})
.def("save_solution_all",
[](TCOPFLOW_wrapper &w, OutputFormat fmt, std::string outdir) {
PetscErrorCode ierr;
ierr = TCCOPFLOWSaveSolutionAll(w.tcopf, fmt, outdir.c_str());
ExaGOCheckError(ierr);
})*/

}
.def("get_convergence_status",
[](TCOPFLOW_wrapper &w) -> bool {
PetscErrorCode ierr;
PetscBool flag;
ierr = TCOPFLOWGetConvergenceStatus(w.tcopf, &flag);
ExaGOCheckError(ierr);
return flag;
})
.def("get_objective",
[](TCOPFLOW_wrapper &w) -> double {
PetscErrorCode ierr;
double obj;
ierr = TCOPFLOWGetObjective(w.tcopf, &obj);
ExaGOCheckError(ierr);
return obj;
})
.def("get_num_iterations", [](TCOPFLOW_wrapper &w) -> int {
PetscErrorCode ierr;
PetscInt n;
ierr = TCOPFLOWGetNumIterations(w.tcopf, &n);
ExaGOCheckError(ierr);
return n;
});
/*.def("save_solution",
[](TCOPFLOW_wrapper &w, OutputFormat fmt, std::string outfile) {
PetscErrorCode ierr;
ierr = TCOPFLOWSaveSolution(w.tcopf, fmt, outfile.c_str());
ExaGOCheckError(ierr);
})
.def("save_solution_all",
[](TCOPFLOW_wrapper &w, OutputFormat fmt, std::string outdir) {
PetscErrorCode ierr;
ierr = TCCOPFLOWSaveSolutionAll(w.tcopf, fmt, outdir.c_str());
ExaGOCheckError(ierr);
})*/
}
2 changes: 1 addition & 1 deletion tests/interfaces/python/test_5_tcopflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ def test_set_model_and_solver():
path = exago.prefix()
opf.read_mat_power_data(os.path.join(
path, 'share', 'exago', 'datafiles', 'case9', 'case9mod.m'))
'''
'''

0 comments on commit 2bc9c7f

Please sign in to comment.