Skip to content

Commit aae4054

Browse files
committed
doc(compose): exemplify links to graphs,
1 parent 7bb1872 commit aae4054

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

docs/source/composition.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The call here to ``compose()`` yields a runnable computation graph that looks li
4646
This yields a graph which looks like this (see :ref:`plotting`):
4747

4848
.. graphtik::
49+
:name: graphop
4950

5051
>>> graphop.plot('calc_power.svg') # doctest: +SKIP
5152

@@ -147,7 +148,12 @@ Run the graph and print the output:
147148
More complicated composition: merging computation graphs
148149
----------------------------------------------------------
149150

150-
Sometimes you will have two computation graphs---perhaps ones that share operations---you want to combine into one. In the simple case, where the graphs don't share operations or where you don't care whether a duplicated operation is run multiple (redundant) times, you can just do something like this::
151+
Sometimes you will have two computation graphs---perhaps ones that share operations---you want to combine into one.
152+
In the simple case, where the graphs don't share operations or where you don't care
153+
whether a duplicated operation is run multiple (redundant) times,
154+
you can just do something like this:
155+
156+
.. code-block::
151157
152158
combined_graph = compose("combined_graph", graph1, graph2)
153159
@@ -165,16 +171,20 @@ For example, let's say we have ``graphop``, as in the examples above, along with
165171
NetworkOperation('another_graph', needs=['a', 'b', 'c', 'ab'], provides=['ab', 'cab'], x2 ops: mul1, mul2)
166172

167173
.. graphtik::
168-
:graphvar: another_graph
174+
:name: another_graph
175+
176+
We can merge :graphtik:`graphop` and :graphtik:`another_graph` like so, avoiding a redundant ``mul1`` operation:
177+
178+
.. Note::
169179

170-
We can merge ``graphop`` and ``another_graph`` like so, avoiding a redundant ``mul1`` operation:
180+
The *names* of the graphs must differ.
171181

172-
>>> merged_graph = compose("merged_graph", graphop, another_graph, merge=True)
173-
>>> print(merged_graph)
174-
NetworkOperation('merged_graph',
175-
needs=['a', 'b', 'ab', 'a_minus_ab', 'c'],
176-
provides=['ab', 'a_minus_ab', 'abs_a_minus_ab_cubed', 'cab'],
177-
x4 ops: mul1, sub1, abspow1, mul2)
182+
>>> merged_graph = compose("merged_graph", graphop, another_graph, merge=True)
183+
>>> print(merged_graph)
184+
NetworkOperation('merged_graph',
185+
needs=['a', 'b', 'ab', 'a_minus_ab', 'c'],
186+
provides=['ab', 'a_minus_ab', 'abs_a_minus_ab_cubed', 'cab'],
187+
x4 ops: mul1, sub1, abspow1, mul2)
178188

179189
.. graphtik::
180190

0 commit comments

Comments
 (0)