def test_dfs_graphs(): g0 = Graph() in0 = Constant(g0) in1 = Constant(1) g0.return_ = in1 value = Apply([in0], Graph()) assert set(dfs(value)) == {value, in0} assert set(dfs(value, follow_graph=True)) == {value, in0, in1}
def test_graph(): """Construct a small graph. Note that this graph is strictly speaking nonsensical, because it doesn't use any actual primitive operations. """ g = Graph() x = Parameter(g) assert x.value is PARAMETER one = Constant(1) add = Constant('add') return_ = Constant('return') value = Apply([add, x, one], g) return_ = Apply([return_, value], g) g.return_ = return_ g.parameters.append(x)