Skip to content

Commit

Permalink
Merge pull request #20 from yasirroni/fix_index_bus_name
Browse files Browse the repository at this point in the history
Fix index bus name
  • Loading branch information
yasirroni authored Nov 21, 2024
2 parents 316687f + 922518e commit cb300cc
Show file tree
Hide file tree
Showing 29 changed files with 2,712 additions and 451 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ octave-workspace

# Local
tests/results/*.xlsx
tests/results/**/*.xlsx


# Playground
playground.ipynb
Expand Down
5 changes: 4 additions & 1 deletion matpowercaseframes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _read_oct2py_struct(self, struct, allow_any_keys=False):
if attribute == "version" or attribute == "baseMVA":
value = list_
elif attribute in ["bus_name", "branch_name", "gen_name"]:
value = pd.Index(list_, name=attribute)
value = pd.Index([name[0] for name in list_], name=attribute)
else: # bus, branch, gen, gencost, dcline, dclinecost
n_cols = list_.shape[1]
value = self._get_dataframe(attribute, list_, n_cols)
Expand Down Expand Up @@ -519,6 +519,9 @@ def to_dict(self):
for attribute in self._attributes:
if attribute == "version" or attribute == "baseMVA":
data[attribute] = getattr(self, attribute)
elif attribute in ["bus_name", "branch_name", "gen_name"]:
# NOTE: must be in 2D Cell or 2D np.array
data[attribute] = np.atleast_2d(getattr(self, attribute).values).T
else:
data[attribute] = getattr(self, attribute).values.tolist()
return data
Expand Down
Loading

0 comments on commit cb300cc

Please sign in to comment.