rwl / PYPOWER

Port of MATPOWER to Python
http://rwl.github.io/PYPOWER/api/
Other
329 stars 110 forks source link

Traceback occurs when using printpf() function #49

Open murilo-ma opened 6 years ago

murilo-ma commented 6 years ago

Python files used when the traceback occurred are attached as .txt files. params_banshee_f1.txt run_banshee_f1.txt

Traceback (most recent call last): File "C:/Users/[...]/POWER FLOW/run_banshee_f1.py", line 26, in printpf(r) File "C:\Python36\lib\site-packages\pypower\printpf.py", line 128, in printpf i2e = bus[:, BUS_I].astype(int) TypeError: 'NoneType' object is not subscriptable

OriolRaventos commented 1 year ago

This is because in the following lines

r = runpf(ppc, ppopt)
printpf(r)

printpf is implemented as if r would be a dictionary with the different entries, but actually "r" is a tuple with one element that is this dictionary. Hence, the error is solved by doing

printpf(r[0])

instead. So I am not sure which is the best way to correct the code.

BTW, the error can be reproduced with the internal data in this way:

from pypower.api import ppoption, runpf, printpf, case9
ppc = case9()
ppopt = ppoption(PF_ALG=2)
r = runpf(ppc, ppopt)
printpf(r)