Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index bus name #20

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading