We'll use the following functions:
def foo(a, b):
return a + b
def bar(x, y):
return x * y
binding to a FuncNode name (id)
The following makes a valid DAG, but it's probably not the one the use wanted.
Here, the dag acts as if there was an extra root var node 'foo' and computes from there.
from meshed import DAG, FuncNode
from i2 import Sig
dag = DAG([
FuncNode(foo, name='foo'),
FuncNode(bar, bind={'y': 'foo'})
])
assert str(Sig(dag)) == '(foo, x, a, b)' # ?!?!
assert dag(9,1,2,3) == (9, 5)
dag.dot_digraph()

binding to a function
dag = DAG([
FuncNode(foo, name='foo'),
FuncNode(bar, bind={'y': foo})
])
# ValidationError: Should be a str: <function foo at 0x121db68b0>
Probably what the user would want in the two cases above is binding the y param to the output of a function.
We could do this automatically for the user.
We'll use the following functions:
binding to a
FuncNodename (id)The following makes a valid DAG, but it's probably not the one the use wanted.
Here, the dag acts as if there was an extra root var node
'foo'and computes from there.binding to a function
Probably what the user would want in the two cases above is binding the
yparam to the output of a function.We could do this automatically for the user.