Skip to content

More static analysis during DAG instantiation #19

Description

@thorwhalen

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()

image

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions