Exemplo n.º 1
0
def test_multiple_builds(Simulator, seed):
    # this is not a separate test because of nengo issue #1011
    solver = BiasedSolver()
    A, Y = np.ones((1, 1)), np.ones((1, 1))
    assert solver.bias is None
    solver(A, Y)
    assert solver.bias is not None
    with warns(UserWarning):
        solver(A, Y)

    # issue: #99
    with Network(seed=seed) as model:
        stim = nengo.Node(output=0)
        x = nengo.Ensemble(100, 1)
        out = nengo.Node(size_in=1)
        nengo.Connection(stim, x, synapse=None)
        conn = Connection(x, out, synapse=None)
        p = nengo.Probe(out, synapse=0.1)

    assert isinstance(conn.solver, BiasedSolver)

    with Simulator(model):
        pass

    with Simulator(model) as sim:
        sim.run(0.1)

    assert rmse(sim.data[p], 0) < 0.01
Exemplo n.º 2
0
def test_balred(rng):
    dt = 0.001
    sys = Alpha(0.01) + Lowpass(0.001)

    u = rng.normal(size=2000)
    expected = sys.filt(u, dt)

    def check(order, within, tol, method='del'):
        redsys = balred(sys, order, method=method)
        assert redsys.order_den <= order
        actual = redsys.filt(u, dt)
        assert abs(rmse(expected, actual) - within) < tol

    with warns(UserWarning):
        check(4, 0, 1e-13)
    with warns(UserWarning):
        check(3, 0, 1e-13)
    check(2, 0.03, 0.01)
    check(1, 0.3, 0.1)
Exemplo n.º 3
0
def test_ntm_invalid_dims(ntm):
    with pytest.raises(ValueError):
        ntm.sample(1, d=0)

    with pytest.raises(ValueError):
        ntm.sample(1, d=1.5)

    if isinstance(ntm, Sobol):
        with warns(UserWarning):
            ntm.sample(2, d=41)
Exemplo n.º 4
0
def test_delay_invalid():
    with warns(UserWarning):
        PadeDelay(1, order=10, p=8)

    with pytest.raises(ValueError):
        PadeDelay(1, order=0)

    with pytest.raises(ValueError):
        PadeDelay(1, order=1)

    with pytest.raises(ValueError):
        PadeDelay(1, order=2.5)

    with pytest.raises(ValueError):
        PadeDelay(1, order=2, p=0)

    with pytest.raises(ValueError):
        PadeDelay(1, order=2, p=1.5)

    with pytest.raises(ValueError):
        LegendreDelay(1, order=3.5)

    with pytest.raises(ValueError):
        LegendreDelay(1, order=-1)
Exemplo n.º 5
0
def test_seed_warning():
    with Network():
        ens = nengo.Ensemble(100, 1)
        res = Reservoir(ens, ens)
        with warns(UserWarning):
            res.train(lambda x: x, 1.0, 0.001, WhiteSignal(1.0, high=10))
Exemplo n.º 6
0
def test_output_warning():
    with warns(UserWarning):
        LinearNetwork(([1, 1], [1, 1]), 1, synapse=1, dt=1)
Exemplo n.º 7
0
def test_unstable_warning():
    with warns(UserWarning):
        with Network():
            LinearNetwork(~s, 1, synapse=0.02, dt=0.001, realizer=Identity())
Exemplo n.º 8
0
def test_filt_issue_nengo1124():
    with warns(UserWarning):
        Lowpass(0.1).filt(np.asarray([1, 0]), dt=0.001, y0=1)

    with warns(UserWarning):
        Lowpass(0.1).filt(np.asarray([1, 0]), dt=0.001, y0=None)