Esempio n. 1
0
def bad_syntax_errors():
    scatter = ecto_test.Scatter(n=3, x=3)
    scatter2 = ecto_test.Scatter(n=5, x=10)

    gather = ecto_test.Gather(n=3)
    gather2 = ecto_test.Gather(n=5)

    try:
        plasm = ecto.Plasm()
        plasm.connect(scatter[:] >> gather2[:])
        util.fail("Should not work as there is a size mismatch...")
    except RuntimeError, e:
        print e
Esempio n. 2
0
def test_plasm():
    scatter = ecto_test.Scatter(n=3, x=3)
    scatter2 = ecto_test.Scatter(n=5, x=10)

    gather = ecto_test.Gather(n=3)
    gather2 = ecto_test.Gather(n=5)
    plasm = ecto.Plasm()

    p = ecto.Plasm()
    #test the old syntax.
    p.connect(scatter, "out_0000", gather, "in_0000")

    try:
        p2 = ecto.Plasm()
        p2.connect(scatter, "out_0000", gather, "idn_0001")
        util.fail()
    except ecto.NonExistant, e:
        print ">>>", e
        assert "'in_0000':type(int) 'in_0001':type(int) 'in_0002':type(int)" in str(
            e)
        print "(threw as expected)\n\n"
Esempio n. 3
0
def test_doc():
    scatter = ecto_test.Scatter(n=6, x=3)
    gather = ecto_test.Gather(n=3)
    gather2 = ecto_test.Gather(n=3)
    plasm = ecto.Plasm()
    plasm.connect(
                  scatter["out_0000","out_0001","out_0002"] >> gather[:],
                  scatter["out_0003","out_0004","out_0005"] >> gather2[:]
                  )
    plasm.execute()
    result = gather.outputs.out
    assert(result == 9) # 3 * 3
    assert scatter.__doc__ != None
    assert gather.__doc__ != None
    assert type(plasm.viz()) == str
Esempio n. 4
0
def test_modules_01():
    g = ecto_test.Generate(start=0, step=2)
    g.process()
    assert g.outputs.out == 0
    g.process()
    assert g.outputs.out == 2
    g.configure()
    print type(g.outputs)
    print type(g.outputs.out)
    print g.outputs.out
    g.outputs.out = 7.0
    g.process()
    assert g.outputs.out == 9
    s = ecto_test.Scatter(n=4, x=3)
    s.process()
    assert (len(s.outputs) == 4)
    for out in s.outputs:
        print out[1].val
        assert (out[1].val == 3)
Esempio n. 5
0
        x = g[2.0]
        util.fail()
    except TypeError, e:
        print e
    try:
        x = g["out", 2.0]
        util.fail()
    except RuntimeError, e:
        print e
    try:
        x = g["out", "and", "about"]
        util.fail()
    except RuntimeError, e:
        print e

    scatter = ecto_test.Scatter(n=3, x=3)
    gather = ecto_test.Gather(n=3)
    a = scatter[scatter.outputs.keys()]
    b = gather[gather.inputs.keys()]
    print a, b
    print a >> b
    plasm = ecto.Plasm()
    plasm.connect(a >> b)
    plasm.execute(1)
    result = gather.outputs.out
    print result
    assert (result == 9)  # 3 * 3

    connections = scatter[:] >> gather[:]
    assert (len(connections) == 3)
    try: