Esempio n. 1
0
def test_create_dot():
    """Constructing a .dot file for a model"""

    model = nengo.Model()
    with model:
        D = 3
        input = nengo.Node([1]*D, label='input')
        a = nengo.networks.EnsembleArray(50, D, label='a')
        b = nengo.networks.EnsembleArray(50, D, label='b')
        output = nengo.Node(None, size_in=D, label='output')

        nengo.Connection(input, a.input, filter=0.01)
        nengo.Connection(a.output, b.input, filter=0.01)
        nengo.Connection(b.output, b.input, filter=0.01, transform=0.9)
        nengo.Connection(a.output, a.input, filter=0.01,
                         transform=np.ones((D, D)))
        nengo.Connection(b.output, output, filter=0.01)

    dot = generate_graphviz(model.objs.values(), model.connections.values())
    assert len(dot.splitlines()) == 31
    # not sure what else to check here

    objs, conns = remove_passthrough_nodes(model.objs.values(),
                                           model.connections.values())

    dot = generate_graphviz(objs, conns)
    assert len(dot.splitlines()) == 27
Esempio n. 2
0
def test_create_dot():
    """Constructing a .dot file for a model"""

    model = nengo.Network()
    with model:
        D = 3
        input = nengo.Node([1] * D, label='input')
        a = nengo.networks.EnsembleArray(50, D, label='a')
        b = nengo.networks.EnsembleArray(50, D, label='b')
        output = nengo.Node(None, size_in=D, label='output')

        nengo.Connection(input, a.input, synapse=0.01)
        nengo.Connection(a.output, b.input, synapse=0.01)
        nengo.Connection(b.output, b.input, synapse=0.01, transform=0.9)
        nengo.Connection(a.output,
                         a.input,
                         synapse=0.01,
                         transform=np.ones((D, D)))
        nengo.Connection(b.output, output, synapse=0.01)

    dot = generate_graphviz(*objs_and_connections(model))
    assert len(dot.splitlines()) == 31
    # not sure what else to check here

    dot = generate_graphviz(*remove_passthrough_nodes(
        *objs_and_connections(model)))
    assert len(dot.splitlines()) == 27
Esempio n. 3
0
def test_moved_error():
    with pytest.raises(MovedError) as excinfo:
        generate_graphviz()

    assert str(excinfo.value) == "This feature has been moved to nengo_extras.graphviz"
    check_tb_entries(
        excinfo.traceback,
        [
            ("test_moved_error", "generate_graphviz()"),
            ("generate_graphviz", 'raise MovedError(location="nengo_extras.graphviz")'),
        ],
    )
Esempio n. 4
0
def test_graphviz_moved():
    with pytest.raises(MovedError):
        generate_graphviz()
Esempio n. 5
0
def test_graphviz_moved():
    with pytest.raises(MovedError):
        generate_graphviz()