Skip to content

Commit 84d25b9

Browse files
author
matt3o
committed
add support for lists to math node
1 parent 1a1b4bf commit 84d25b9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

essentials.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,8 @@ def execute(self, image, amount):
10431043

10441044
op_functions = {
10451045
'min': min,
1046-
'max': max
1046+
'max': max,
1047+
'round': round,
10471048
}
10481049

10491050
class SimpleMath:
@@ -1083,6 +1084,12 @@ def eval_(node):
10831084
if node.func.id in op_functions:
10841085
args =[eval_(arg) for arg in node.args]
10851086
return op_functions[node.func.id](*args)
1087+
elif isinstance(node, ast.Subscript): # indexing or slicing
1088+
value = eval_(node.value)
1089+
if isinstance(node.slice, ast.Constant):
1090+
return value[node.slice.value]
1091+
else:
1092+
return 0
10861093
else:
10871094
return 0
10881095

@@ -1898,7 +1905,6 @@ def execute(self, image_1, image_2, method, image_3=None, image_4=None, image_5=
18981905

18991906
return (out,)
19001907

1901-
19021908
NODE_CLASS_MAPPINGS = {
19031909
"GetImageSize+": GetImageSize,
19041910

0 commit comments

Comments
 (0)