rwl / PYPOWER

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

Savecase() fixes supporting Python 2 and 3. #26

Closed nickpowersys closed 8 years ago

nickpowersys commented 8 years ago

This update automatically uses the correct write mode for Python 3 or Python 2. It addresses an indexing-related issue with writing to .py files. I added a new t_savecase.py file with a t_savecase() test. This is original with PYPOWER, rather than being ported from MATPOWER.

For writing to .mat files, I have maintained a close correspondence to the steps in MATPOWER's savecase.m so it is easy to compare the two versions. The savemat() function in SciPy works consistently when non-scalar values are in the form of NumPy arrays, so I have done conversion before assigning the values to the case dict.