#NEWLINE# def evalnode( func = None , filter = None , category = None ) : #NEWLINE# #INDENT# "\n    Decorator for creating an :py:class:`MDFNode` whose value is determined\n    by calling the function func.\n\n    **func** should be a function or generator that takes no arguments and\n    returns or yields the current value of the node.\n\n    If *func* is a generator instead of a function it will be advanced as\n    the :py:func:`now` node is advanced. This can be used to calculate\n    accumulated values and maintain internal state over evaluations::\n\n        @evalnode\n        def some_function():\n            # Set initial value of 'accum' to 0\n            accum = 0\n\n            # yield the initial value of 'accum' (0 in this case)\n            yield accum\n\n            while True:\n                accum += 1\n                # yield the updated value of 'accum' on each evaluation\n                yield accum\n\n    Yield essentially bookmarks the current execution point, and returns\n    the supplied value (accum in the above example). When the node is\n    evaluated again, execution will resume at the bookmark and continue\n    until the next yield statement is encountered. By using an infinite\n    while loop the node can be evaluated any number of times.\n\n    The above example can actually be shortened to::\n\n        @evalnode\n        def some_function():\n            # Set initial value of 'accum' to 0\n            accum = 0\n\n            while True:\n                yield accum\n                accum += 1\n\n    In this case, yield will first return the initial value of 'accum'.\n    On subsequent evaluations, the incrementation step will be also\n    executed and the node will produce the updated value.\n\n    **filter** may be used in the case when *func* is a generator to prevent\n    the node valuation being advanced on every timestep. If supplied, it\n    should be a function or node that returns True if the node should\n    be advanced for the current timestep or False otherwise.\n    " #NEWLINE# if func : #NEWLINE# #INDENT# return MDFEvalNode ( func , category = filter , filter = filter ) #NEWLINE# #UNINDENT# return ( lambda x : evalnode ( x , filter , category ) )