File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
computation_graph/composers Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ def filter_computation_errors(*args):
107
107
)
108
108
109
109
110
+ _destinations = gamla .compose (set , gamla .map (base_types .edge_destination ))
111
+
112
+
110
113
def _infer_sink (graph_or_node : base_types .NodeOrGraph ) -> base_types .ComputationNode :
111
114
if isinstance (graph_or_node , base_types .ComputationNode ):
112
115
return graph_or_node
@@ -130,8 +133,8 @@ def _infer_sink(graph_or_node: base_types.NodeOrGraph) -> base_types.Computation
130
133
assert len (result ) == 1
131
134
return gamla .head (result )
132
135
133
- assert len (graph_or_node ) == 1 , graph_without_future_edges
134
- return graph_or_node [0 ]. destination
136
+ assert len (_destinations ( graph_or_node )) == 1 , graph_or_node
137
+ return base_types . edge_destination ( graph_or_node [0 ])
135
138
136
139
137
140
def make_first (* graphs : base_types .CallableOrNodeOrGraph ) -> base_types .GraphType :
Original file line number Diff line number Diff line change 1
- from computation_graph import composers , graph_runners
1
+ import computation_graph .graph
2
+ from computation_graph import base_types , composers , graph_runners
2
3
3
4
4
5
def test_unary_composition_with_graph_destination ():
@@ -11,6 +12,20 @@ def test_unary_composition_with_graph_destination():
11
12
assert result == - 1
12
13
13
14
15
+ def test_infer_sink_edge_case_all_future_edges_with_single_destination ():
16
+ s = computation_graph .graph .make_source ()
17
+
18
+ def c_b (c , b ):
19
+ return b
20
+
21
+ two_future_edges_single_dest = base_types .merge_graphs (
22
+ composers .compose_left_source (s , "c" , c_b ),
23
+ composers .compose_left_source (s , "b" , c_b ),
24
+ )
25
+
26
+ composers .compose_left_unary (two_future_edges_single_dest , lambda x : x )
27
+
28
+
14
29
def test_ambiguity_does_not_blow_up ():
15
30
counter = 0
16
31
Original file line number Diff line number Diff line change 7
7
setuptools .setup (
8
8
name = "computation-graph" ,
9
9
python_requires = ">=3" ,
10
- version = "37 " ,
10
+ version = "38 " ,
11
11
long_description = _LONG_DESCRIPTION ,
12
12
long_description_content_type = "text/markdown" ,
13
13
packages = setuptools .find_namespace_packages (),
You can’t perform that action at this time.
0 commit comments