Skip to content

Commit

Permalink
Add test for input synapses
Browse files Browse the repository at this point in the history
This is the test from #63 with additional filtering because
Nengo Loihi drifts a little bit over time.

Addresses #63.
  • Loading branch information
tbekolay committed Oct 9, 2019
1 parent df4d54f commit 8196aad
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions nengo_loihi/tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,33 @@ def test_sparse_ens_ens(Simulator, seed, plt, allclose):

assert allclose(sim.data[bp][:, 0], -0.8 * sim.data[up][:, 2], atol=0.2)
assert allclose(sim.data[bp][:, 1], 0.6 * sim.data[up][:, 0], atol=0.2)


def test_input_synapses(Simulator, allclose, plt):
synapse = 0.1
with nengo.Network() as net:
stim = nengo.Node(lambda t: 1 if t % 0.5 < 0.25 else 0)
ens = nengo.Ensemble(
n_neurons=1, dimensions=1, encoders=[[1]], intercepts=[0], max_rates=[50]
)
nengo.Connection(stim, ens, synapse=synapse)
p_stim = nengo.Probe(stim)
p_neurons = nengo.Probe(ens.neurons)

with Simulator(net) as sim:
sim.run(0.5)
with nengo.Simulator(net) as ref:
ref.run(0.5)

t = sim.trange()
ref_filt = nengo.Alpha(0.03).filtfilt(ref.data[p_neurons])
sim_filt = nengo.Alpha(0.03).filtfilt(sim.data[p_neurons])

plt.plot(t, ref_filt, label="nengo")
plt.plot(t, sim_filt, label="nengo_loihi")
plt.legend(loc="best")
plt.twinx()
plt.plot(t, sim.data[p_stim], c="k")

# Only looking at t < 0.4 as there are weird effects at the end
assert allclose(ref_filt[t < 0.4], sim_filt[t < 0.4], atol=1.5)

0 comments on commit 8196aad

Please sign in to comment.