Skip to content

Commit

Permalink
warning instead of error when fail to install matpower if already ins…
Browse files Browse the repository at this point in the history
…talled
  • Loading branch information
yasirroni committed May 29, 2024
1 parent fadae1c commit 610c5e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion matpowerpip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
import warnings


class Matpower:
Expand Down Expand Up @@ -43,7 +44,12 @@ def start_instance(path_matpower=None, engine="octave", save_path=False):
path_matpower = PATH_MATPOWER

m.addpath(path_matpower)
m.install_matpower(1, 0, 0) # TODO: explain what is (1, 0, 0)
try:
m.install_matpower(1, 0, 0) # TODO: explain what is (1, 0, 0)
except Exception as e:
# Oct2PyError
warnings.warn(e, stacklevel=2)

m.rmpath(path_matpower)

if save_path:
Expand Down
8 changes: 5 additions & 3 deletions notebooks/runopf_pypglib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
}
],
"source": [
"import matpower\n",
"import oct2py\n",
"\n",
"import matpower\n",
"\n",
"print(f\"oct2py version: {oct2py.__version__}\")\n",
"print(f\"matpower version: {matpower.__version__}\")"
]
Expand All @@ -55,9 +56,10 @@
"metadata": {},
"outputs": [],
"source": [
"from matpower import start_instance\n",
"from matpowercaseframes import CaseFrames\n",
"from pypglib import pglib_opf_case5_pjm"
"from pypglib import pglib_opf_case5_pjm\n",
"\n",
"from matpower import start_instance"
]
},
{
Expand Down

0 comments on commit 610c5e0

Please sign in to comment.