diff --git a/simra.py b/simra.py index 452c5f0323ff098f6c1f1bb550cebdf83bd28303..9bfb3b0c4815b755eb3bd4d337a07b2e054be0c3 100755 --- a/simra.py +++ b/simra.py @@ -236,15 +236,24 @@ def periodic_mode(mode): # Trivial nodes def node_fixpoint(name, init_val=0): + """ + Return a node that depends only on itself and updates to its own value. + """ def identity(args): for k in args.keys(): return args[k] return Node(name, identity, [name], init_val) -def node_constant(name, value=0, init_val=value): +def node_constant(name, value=0, init_val=None): + """ + Return a node that depends on nobody and update to the given value. + """ + if not init_val: init_val=value + def constant(args): nonlocal value return value + return Node(name, constant, [], init_val) # ################################################################