Skip to content

Commit 0ae862c

Browse files
committed
Update op_compiler.py
Moved lambda generation to external method to stop side effects
1 parent b1d3f91 commit 0ae862c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ngcsimlib/compilers/process_compiler/op_compiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from ngcsimlib.operations.baseOp import BaseOp
22

3+
def _make_lambda(s):
4+
return lambda current_state, **kwargs: current_state[s.path]
5+
36
def compile(op):
47
"""
58
compiles the operation down to its execution order
@@ -15,7 +18,7 @@ def compile(op):
1518
if isinstance(s, BaseOp):
1619
arg_methods.append(compile(s))
1720
else:
18-
arg_methods.append(lambda current_state, **kwargs: current_state[s.path])
21+
arg_methods.append(_make_lambda(s))
1922

2023
def compiled(current_state, **kwargs):
2124
argvals = [m(current_state, **kwargs) for m in arg_methods]

0 commit comments

Comments
 (0)