def execute_plasm(self, Sched, nthreads, niter, n_nodes, incdelay): plasm = ecto.Plasm() gen = ecto_test.Generate("Gen", step=1.0, start=0.0) inc = ecto_test.Increment("Increment 0", delay=incdelay) plasm.connect(gen, "out", inc, "in") for j in range(n_nodes - 1): # one has already been added inc_next = ecto_test.Increment("Increment_%u" % (j + 1), delay=incdelay) plasm.connect(inc, "out", inc_next, "in") inc = inc_next printer = ecto_test.Printer("Printy") plasm.connect(inc, "out", printer, "in") # # o = open('graph.dot', 'w') # print >>o, plasm.viz() # o.close() # print "\n", plasm.viz(), "\n" sched = Sched(plasm) sched.execute(niter) print("RESULT:", inc.outputs.out) shouldbe = float(n_nodes + niter - 1) print("expected:", shouldbe) assert inc.outputs.out == shouldbe
def test_0_save_plasm(self): n_nodes = 5 incdelay = 1 plasm = ecto.Plasm() gen = ecto_test.Generate("Gen", step=1.0, start=0.0) inc = ecto_test.Increment("Increment 0", delay=incdelay) plasm.connect(gen, "out", inc, "in") for j in range(n_nodes - 1): # one has already been added inc_next = ecto_test.Increment("Increment_%u" % (j + 1), delay=incdelay) plasm.connect(inc, "out", inc_next, "in") inc = inc_next printer = ecto_test.Printer("Printy") plasm.connect(inc, "out", printer, "in") plasm.save(self.FILE)
def test_dual_line_plasm(nlevels): plasm = ecto.Plasm() gen = ecto_test.Generate(step=1.0, start=0.0) incl, incr = ecto_test.Increment(), ecto_test.Increment() plasm.connect(gen, "out", incl, "in") plasm.connect(gen, "out", incr, "in") for j in range(nlevels - 1): # one set of incs has already been added print j inc_nextl, inc_nextr = ecto_test.Increment(), ecto_test.Increment() plasm.connect(incl, "out", inc_nextl, "in") plasm.connect(incr, "out", inc_nextr, "in") incl, incr = inc_nextl, inc_nextr add = ecto_test.Add() plasm.connect(incl, "out", add, "left") plasm.connect(incr, "out", add, "right") printer = ecto_test.Printer() plasm.connect(add, "out", printer, "in") sched = ecto.Scheduler(plasm) sched.execute(niter=1) result = add.outputs.out print "result=", result assert (result == nlevels * 2) sched.execute(niter=2) result = add.outputs.out print "iter2 result=", result assert result == (nlevels + 2) * 2 sched.execute(niter=3) result = add.outputs.out print "iter3 result=", result assert result == (nlevels + 5) * 2
#!/usr/bin/env python import ecto, sys import ecto.ecto_test as ecto_test plasm = ecto.Plasm() gen = ecto_test.Generate("Gen", step=1.0, start=0.0) inc = ecto_test.Increment("Increment 0", delay=100) printer = ecto_test.Printer("Printy") plasm.connect(gen[:] >> inc[:], inc[:] >> printer[:]) sched = ecto.schedulers.Threadpool(plasm) sched.execute_async(niter=10) from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed() ipshell()
#!/usr/bin/python import ecto import ecto.ecto_test as ecto_test plasm = ecto.Plasm() gen = ecto_test.Generate() inc = ecto_test.Increment() mul = ecto_test.Multiply() add = ecto_test.Add() plasm.connect(gen[:] >> inc[:], gen[:] >> mul[:], mul[:] >> add['left'], inc[:] >> add['right'], )