rwl / PYPOWER

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

ext2int function: bus numbering requires integer values instead of float numbers #41

Open johnschu647 opened 7 years ago

johnschu647 commented 7 years ago

I found a issue in the "ext2int" function related to false indexing of the consecutive bus numbering in row 152 (see following code). The dictonary data type requires integer indices instead of float numbers that are used currently. The issue appears with the latest numpy version "1.12.0" (it doesn't ignore anymore false indexing with float numbers).

Current implementation (error appears in row 152):

## apply consecutive bus numbering
           o["bus"]["i2e"] = ppc["bus"][:, BUS_I].copy()
           o["bus"]["e2i"] = zeros(max(o["bus"]["i2e"]) + 1)

Manual fix by changing the code in row 151 (it's not pretty, I know, but it works):

## apply consecutive bus numbering
            o["bus"]["i2e"] = ppc["bus"][:, BUS_I].copy().astype(int)
            o["bus"]["e2i"] = zeros(max(o["bus"]["i2e"]) + 1)