@@ -25,9 +25,9 @@ The call here to ``compose()`` yields a runnable computation graph that looks li
2525
2626 >>> # Compose the mul, sub, and abspow operations into a computation graph.
2727 >>> formula = compose(" maths" ,
28- ... operation(name = " mul1" , needs = [" a " , " b " ], provides = [" ab " ])(mul),
29- ... operation(name = " sub1" , needs = [" a " , " ab " ], provides = [" a-ab " ])(sub),
30- ... operation(name = " abspow1" , needs = [" a-ab " ], provides = [" |a-ab |³" ])
28+ ... operation(name = " mul1" , needs = [" α " , " β " ], provides = [" α×β " ])(mul),
29+ ... operation(name = " sub1" , needs = [" α " , " α×β " ], provides = [" α-α×β " ])(sub),
30+ ... operation(name = " abspow1" , needs = [" α-α×β " ], provides = [" |α-α×β |³" ])
3131 ... (partial(abspow, p = 3 ))
3232 ... )
3333
@@ -49,9 +49,9 @@ with keys corresponding to the named :term:`dependencies <dependency>` (`needs`
4949`provides `):
5050
5151 >>> # Run the graph and request all of the outputs.
52- >>> out = formula(a = 2 , b = 5 )
52+ >>> out = formula(α = 2 , β = 5 )
5353 >>> out
54- {'a ': 2, 'b ': 5, 'ab ': 10, 'a-ab ': -8, '|a-ab |³': 512}
54+ {'α ': 2, 'β ': 5, 'α×β ': 10, 'α-α×β ': -8, '|α-α×β |³': 512}
5555
5656You may plot the solution:
5757
@@ -66,11 +66,11 @@ the pipeline, to see which operations will be included in the :term:`graph`
6666(assuming the graph is solvable at all), based on the given :term: `inputs `/:term: `outputs `
6767combination:
6868
69- >>> plan = formula.compile(inputs = [' a ' , ' b ' ], outputs = ' a-ab ' )
69+ >>> plan = formula.compile(inputs = [' α ' , ' β ' ], outputs = ' α-α×β ' )
7070 >>> plan
71- ExecutionPlan(needs=['a ', 'b '],
72- provides=['a-ab '],
73- x5 steps: mul1, b , sub1, a, ab )
71+ ExecutionPlan(needs=['α ', 'β '],
72+ provides=['α-α×β '],
73+ x5 steps: mul1, β , sub1, α, α×β )
7474 >>> plan.validate() # all fine
7575
7676.. _pruned-explanations :
@@ -91,15 +91,15 @@ of execution:
9191But if an impossible combination of `inputs ` & `outputs `
9292is asked, the plan comes out empty:
9393
94- >>> plan = formula.compile(inputs = ' a ' , outputs = " a-ab " )
94+ >>> plan = formula.compile(inputs = ' α ' , outputs = " α-α×β " )
9595 >>> plan
9696 ExecutionPlan(needs=[], provides=[], x0 steps: )
9797 >>> plan.validate()
9898 Traceback (most recent call last):
9999 ValueError: Unsolvable graph:
100100 +--Network(x8 nodes, x3 ops: mul1, sub1, abspow1)
101- +--possible inputs: ['a ', 'b ', 'ab ', 'a-ab ']
102- +--possible outputs: ['ab ', 'a-ab ', '|a-ab |³']
101+ +--possible inputs: ['α ', 'β ', 'α×β ', 'α-α×β ']
102+ +--possible outputs: ['α×β ', 'α-α×β ', '|α-α×β |³']
103103
104104Evictions: producing a subset of outputs
105105^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -110,9 +110,9 @@ You can use the ``outputs`` parameter to request only a subset.
110110For example, if ``formula `` is as above:
111111
112112 >>> # Run the graph-operation and request a subset of the outputs.
113- >>> out = formula.compute({' a ' : 2 , ' b ' : 5 }, outputs = " a-ab " )
113+ >>> out = formula.compute({' α ' : 2 , ' β ' : 5 }, outputs = " α-α×β " )
114114 >>> out
115- {'a-ab ': -8}
115+ {'α-α×β ': -8}
116116
117117.. graphtik ::
118118
@@ -141,12 +141,12 @@ Short-circuiting a pipeline
141141You can short-circuit a graph computation, making certain inputs unnecessary,
142142by providing a value in the graph that is further downstream in the graph than those inputs.
143143For example, in the graph-operation we've been working with, you could provide
144- the value of ``a-ab `` to make the inputs ``a `` and ``b `` unnecessary:
144+ the value of ``α-α×β `` to make the inputs ``α `` and ``β `` unnecessary:
145145
146146 >>> # Run the graph-operation and request a subset of the outputs.
147- >>> out = formula.compute({" a-ab " : - 8 })
147+ >>> out = formula.compute({" α-α×β " : - 8 })
148148 >>> out
149- {'a-ab ': -8, '|a-ab |³': 512}
149+ {'α-α×β ': -8, '|α-α×β |³': 512}
150150
151151.. graphtik ::
152152
@@ -172,22 +172,22 @@ unexpectedly, fail with ``Unsolvable graph`` error -- all :term:`dependencies <d
172172have already values, therefore any operations producing them are :term: `prune `\d out,
173173till no operation remains:
174174
175- >>> new_inp = formula.compute({" a " : 2 , " b " : 5 })
176- >>> new_inp[" a " ] = 20
175+ >>> new_inp = formula.compute({" α " : 2 , " β " : 5 })
176+ >>> new_inp[" α " ] = 20
177177 >>> formula.compute(new_inp)
178178 Traceback (most recent call last):
179179 ValueError: Unsolvable graph:
180180 +--Network(x8 nodes, x3 ops: mul1, sub1, abspow1)
181- +--possible inputs: ['a ', 'b ', 'ab ', 'a-ab ']
182- +--possible outputs: ['ab ', 'a-ab ', '|a-ab |³']
181+ +--possible inputs: ['α ', 'β ', 'α×β ', 'α-α×β ']
182+ +--possible outputs: ['α×β ', 'α-α×β ', '|α-α×β |³']
183183
184184
185185One way to proceed is to avoid recompiling, by executing directly the pre-compiled
186186:term: `plan `, which will run all the original operations on the new values:
187187
188188 >>> sol = new_inp.plan.execute(new_inp)
189189 >>> sol
190- {'a ': 20, 'b ': 5, 'ab ': 100, 'a-ab ': -80, '|a-ab |³': 512000}
190+ {'α ': 20, 'β ': 5, 'α×β ': 100, 'α-α×β ': -80, '|α-α×β |³': 512000}
191191 >>> [op.name for op in sol.executed]
192192 ['mul1', 'sub1', 'abspow1']
193193
@@ -198,17 +198,17 @@ One way to proceed is to avoid recompiling, by executing directly the pre-compil
198198But that trick wouldn't work if the modified value is an inner dependency
199199of the :term: `graph ` -- in that case, the operations upstream would simply overwrite it:
200200
201- >>> new_inp[" a-ab " ] = 123
201+ >>> new_inp[" α-α×β " ] = 123
202202 >>> sol = new_inp.plan.execute(new_inp)
203- >>> sol[" a-ab " ] # should have been 123!
203+ >>> sol[" α-α×β " ] # should have been 123!
204204 -80
205205
206206You can still do that using the ``recompute_from `` argument of :meth: `.Pipeline.compute() `.
207207It accepts a string/list of dependencies to :term: `recompute `, *downstream *:
208208
209- >>> sol = formula.compute(new_inp, recompute_from = " a-ab " )
209+ >>> sol = formula.compute(new_inp, recompute_from = " α-α×β " )
210210 >>> sol
211- {'a ': 20, 'b ': 5, 'ab ': 10, 'a-ab ': 123, '|a-ab |³': 1860867}
211+ {'α ': 20, 'β ': 5, 'α×β ': 10, 'α-α×β ': 123, '|α-α×β |³': 1860867}
212212 >>> [op.name for op in sol.executed]
213213 ['abspow1']
214214
@@ -218,7 +218,7 @@ The old values are retained, although the operations producing them
218218have been pruned from the plan.
219219
220220.. Note ::
221- The value of ``a-ab `` is no longer *the correct result * of ``sub1 `` operation,
221+ The value of ``α-α×β `` is no longer *the correct result * of ``sub1 `` operation,
222222 above it (hover to see ``sub1 `` inputs & output).
223223
224224
0 commit comments