From 6464987eec3a0b9470433fbea6814011567086d3 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Tue, 23 Feb 2021 12:02:43 +0100 Subject: [PATCH] Handle scalar equ & var in DatabaseBackend.item_get_elements() --- ixmp/backend/dbapi.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ixmp/backend/dbapi.py b/ixmp/backend/dbapi.py index a26ed4009..c237c4993 100644 --- a/ixmp/backend/dbapi.py +++ b/ixmp/backend/dbapi.py @@ -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): @@ -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