Skip to content

Commit 9d7c5d9

Browse files
committed
Update filter_by_predicate for clingo to support select multiple predicates
1 parent 309d783 commit 9d7c5d9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/geist/datastore/clingo.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ def format_dicts(dicts, returnformat):
3838
def filter_by_predicate(dicts, predicate):
3939
filtered_dicts = []
4040
for one_case in dicts:
41-
filtered_dict = {predicate: one_case[predicate]} if predicate in one_case else {predicate: []}
41+
if type(predicate) == str:
42+
filtered_dict = {predicate: one_case.get(predicate, [])}
43+
elif type(predicate) == list:
44+
filtered_dict = {p: one_case.get(p, []) for p in predicate}
45+
else:
46+
raise ValueError(f"Unsupported predicate type: {type(predicate)}")
4247
filtered_dicts.append(filtered_dict)
4348
return filtered_dicts
4449

0 commit comments

Comments
 (0)