Skip to content

Commit

Permalink
Handle scalar equ & var in DatabaseBackend.item_get_elements()
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Feb 23, 2021
1 parent 58b25b0 commit 6464987
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ixmp/backend/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ def item_get_elements(self, s, type, name, filters):
if data is None:
cur.execute("SELECT dims from item WHERE id = ?", (id,))
dims = eval(cur.fetchone()[0])
idx_names, idx_sets = list(zip(*dims.items()))
idx_names, idx_sets = (
list(zip(*dims.items())) if len(dims) else (tuple(), tuple())
)
data = tuple()

if len(idx_sets):
Expand All @@ -337,7 +339,11 @@ def item_get_elements(self, s, type, name, filters):

# Create data frame
result = pd.DataFrame(data, columns=columns).astype(dtypes)
elif type in ("equ", "var"):
# Scalar equations and variables
result = dict(zip(("lvl", "mrg"), data))
else:
print(s, type, name, filters, data, idx_names, idx_sets)
raise NotImplementedError("non-indexed items")

return result
Expand Down

0 comments on commit 6464987

Please sign in to comment.