22from ngcsimlib .compartment import Compartment
33from ngcsimlib .compilers .utils import compose
44
5+ def __make_get_arg (a ):
6+ return lambda current_state , ** kwargs : kwargs .get (a , None )
7+
8+ def __make_get_param (p , component ):
9+ lambda current_state , ** kwargs : component .__dict__ .get (p , None )
10+
11+ def __make_get_comp (c , component ):
12+ return lambda current_state , ** kwargs : current_state .get (component .__dict__ [c ].path , None )
13+
14+
515def compile (transition_method ):
616 composition = None
717 component = transition_method .__self__
@@ -27,14 +37,15 @@ def compile(transition_method):
2737 composition = compose (composition , op_compile (conn ))
2838
2939 arg_methods = []
40+ print (compartments )
3041 for a in args :
31- arg_methods .append ((a , lambda current_state , ** kwargs : kwargs . get ( a , None )))
42+ arg_methods .append ((a , __make_get_arg ( a )))
3243
3344 for p in parameters :
34- arg_methods .append ((p , lambda current_state , ** kwargs : component . __dict__ . get (p , None )))
45+ arg_methods .append ((p , __make_get_param (p , component )))
3546
3647 for c in compartments :
37- arg_methods .append ((c , lambda current_state , ** kwargs : current_state . get ( component . __dict__ [ c ]. path , None )))
48+ arg_methods .append ((c , __make_get_comp ( c , component )))
3849
3950 def compiled (current_state , ** kwargs ):
4051 kargvals = {key : m (current_state , ** kwargs ) for key , m in arg_methods }
0 commit comments