in pythonflow/core.py [0:0]
def evaluate(self, context, callback=None):
"""
Evaluate the operation given a context.
Parameters
----------
context : dict
Normalised context in which to evaluate the operation.
callback : callable or None
Callback to be evaluated when an operation is evaluated.
Returns
-------
value : object
Output of the operation given the context.
"""
# Evaluate all explicit dependencies first
self.evaluate_dependencies(context, callback)
if self in context:
return context[self]
# Evaluate the parents
partial = functools.partial(self.evaluate_operation, context=context, callback=callback)
args = [partial(arg) for arg in self.args]
kwargs = {key: partial(value) for key, value in self.kwargs.items()}
# Evaluate the operation
callback = callback or _noop_callback
with callback(self, context):
context[self] = value = self._evaluate(*args, **kwargs)
return value