Skip to content

Commit 2769d56

Browse files
Simplify boolean logic.
1 parent 317c1cf commit 2769d56

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

datajoint/condition.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ def prep_value(k, v):
152152
return f'{k}="{v}"'
153153
return f"{k}={v}"
154154

155-
def combine_conditions(negate, restrictions, operator="AND"):
156-
return ("NOT %s" if negate else "%s") % (
157-
f"({f') {operator} ('.join(restrictions)})"
158-
)
155+
def combine_conditions(negate, restrictions):
156+
return f"{'NOT ' if negate else ''} ({')AND('.join(restrictions)})"
159157

160158
negate = False
161159
while isinstance(condition, Not):
@@ -269,7 +267,7 @@ def combine_conditions(negate, restrictions, operator="AND"):
269267
if any(item is True for item in or_list): # if any item is True, entirely True
270268
return not negate
271269
return (
272-
combine_conditions(negate, restrictions=or_list, operator="OR")
270+
f"{'NOT ' if negate else ''} ({' OR '.join(or_list)})"
273271
if or_list
274272
else negate
275273
)

0 commit comments

Comments
 (0)