Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular eventspaces fail when source group runs on a different clock than synapses #222

Open
denisalevi opened this issue Aug 4, 2021 · 0 comments

Comments

@denisalevi
Copy link
Member

denisalevi commented Aug 4, 2021

SpikeGeneratorClock(..., dt=2*defaultclock.dt) produces wrong results in the following test:

@attr('standalone-compatible')
@with_setup(teardown=reinit_and_delete)
def test_circular_eventspaces_different_clock():
# same test as test_circular_eventspaces_spikegenerator() but with a
# SpikeGeneratorGroup on a different clock (dt=2*defaultclock.dt)
default_dt = defaultclock.dt
# Neuron 0 spikes every second time step in first n_timesteps
clock_multiplier = 2 # factor by which SpikeGeneratorGroup clock is slower
n_timesteps = 12
indices = [0] * (n_timesteps // clock_multiplier)
times = arange(0, n_timesteps, clock_multiplier) * default_dt
inp = SpikeGeneratorGroup(1, indices, times, dt=2*default_dt)
G = NeuronGroup(5, 'v:1', threshold='v>1', reset='v=0')
# synapses with homogenous delays
S0 = Synapses(inp, G, on_pre='v+=1.1', delay=0*ms)
S0.connect(i=0, j=0)
S1 = Synapses(inp, G, on_pre='v+=1.1', delay=2*default_dt)
S1.connect(i=0, j=1)
S2 = Synapses(inp, G, on_pre='v+=1.1', delay=4*default_dt)
S2.connect(i=0, j=2)
# synapse with heterogeneous delays
S3 = Synapses(inp, G, on_pre='v+=1.1')
S3.connect(i=0, j=[3, 4]) # delays: 6, 8
S3.delay = '2*j*default_dt'
mon = SpikeMonitor(G)
run((n_timesteps + 9) * default_dt, profile=profile)
# neurons should spike in the timestep after effect application
assert_allclose(mon.t[mon.i[:] == 0], arange(1, n_timesteps + 1, clock_multiplier) * default_dt)
assert_allclose(mon.t[mon.i[:] == 1], arange(3, n_timesteps + 3, clock_multiplier) * default_dt)
assert_allclose(mon.t[mon.i[:] == 2], arange(5, n_timesteps + 5, clock_multiplier) * default_dt)
assert_allclose(mon.t[mon.i[:] == 3], arange(7, n_timesteps + 7, clock_multiplier) * default_dt)
assert_allclose(mon.t[mon.i[:] == 4], arange(9, n_timesteps + 9, clock_multiplier) * default_dt)

This could be a general issue of how we compute the circular eventspaces and might also apply to a normal thresholder running on a different clock (should be tested!).

EDIT:
This does also apply to NeuronGroup on a different clock. I renamed the test above to test_circular_evenstpace_different_clock_spikegenerator and added another test with NeuronGroup names test_circular_evenstpace_different_clock_neurongroup.

denisalevi added a commit that referenced this issue Aug 4, 2021
Update and fix spikegenerator.
Fixes #48.
New issue for spikegenerator on differnt clock in #222 
Additional optimization suggestions in #193
@denisalevi denisalevi changed the title Circular eventspaces fail when SpikeGeneratorGroup runs on a different clock Circular eventspaces fail when source group runs on a different clock than synapses Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant