コード例 #1
0
 def testNormalPort(self):
     c1 = Component('c1')
     c1.outputs.add(OutputPort('a'))
     c2 = Component('c2')
     c2.inputs.add(InputPort('b'))
     graph = Multigraph()
     graph.connect(c1.outputs['a'], c2.inputs['b'])
     with open('/home/baffelli/normal.dot', 'w+') as outfile:
         outfile.write(graph.dot())
コード例 #2
0
 def testArrayPort(self):
     c1 = Component('c1')
     c1.outputs.add(OutputPort('a'))
     c2 = Component('c2')
     c2.inputs.add(InputPort('b'))
     c2.inputs.add(InputPort('c'))
     graph = Multigraph()
     graph.connect(c1.outputs['a'], c2.inputs['b'])
     graph.connect(c1.outputs['a'], c2.inputs['c'])
     print(list(graph.iterarcs()))
     with open('/home/baffelli/multiport.dot', 'w+') as outfile:
         outfile.write(graph.dot())
コード例 #3
0
 def testSumPipeline(self):
     source1 = GeneratorSource('s1', (i for i in range(100)))
     source2 = GeneratorSource('s2', (i for i in range(100)))
     shower = ShowInputs('printer')
     shower.inputs.add(InputPort('in1'))
     summer = BroadcastApplyFunction('summer', adder)
     summer.inputs.add(InputPort('g1'))
     summer.inputs.add(InputPort('g2'))
     summer.outputs.add(OutputPort('sum'))
     graph = Multigraph()
     graph.connect(source1.outputs.OUT, summer.inputs.g1)
     graph.connect(source2.outputs.OUT, summer.inputs.g2)
     graph.connect(summer.outputs.sum, shower.inputs.in1)
     with open('/home/baffelli/sum.dot', 'w+') as outfile:
         outfile.write(graph.dot())
     graph()
コード例 #4
0
 def testRecursivePipeline(self):
     source1 = GeneratorSource('s1', (i for i in range(1000)))
     shower = ShowInputs('printer')
     shower.inputs.add(InputPort('in1'))
     summer = BroadcastApplyFunction('summer', adder)
     summer.inputs.add(InputPort('g1'))
     summer.inputs.add(InputPort('recursion'))
     summer.outputs.add(OutputPort('sum'))
     graph = Multigraph()
     graph.connect(source1.outputs.OUT, summer.inputs.g1)
     graph.connect(summer.outputs.sum, shower.inputs.in1)
     graph.connect(summer.outputs.sum, summer.inputs.recursion)
     #Add a kickstarter to a port
     graph.set_kickstarter(summer.inputs.recursion)
     with open('/home/baffelli/recursion.dot', 'w+') as outfile:
         outfile.write(graph.dot())
     graph()
コード例 #5
0
 def testProduct(self):
     source1 = GeneratorSource('s1')
     source2 = GeneratorSource('s2')
     range(5) >> source1.inputs.gen
     range(5) >> source2.inputs.gen
     p = components.Product('prod')
     printer = ShowInputs('printer')
     printer.inputs.add(InputPort('IN'))
     p.inputs.add(InputPort('i'))
     p.inputs.add(InputPort('j'))
     p.outputs.add(OutputPort('OUT'))
     g = Multigraph('cul')
     g.connect(source1.outputs.OUT, p.inputs.i)
     g.connect(source2.outputs.OUT, p.inputs.j)
     g.connect(p.outputs.OUT, printer.inputs.IN)
     print(list(g.iterarcs()))
     print(g.dot())
     g()