def test_psg_variable(): times = np.linspace(0.0, 10.0, 1000) fr = np.exp(-np.power(times - 5.0, 2) / (2*np.power(.5, 2)))*5 psg = PoissonSpikeGenerator(population='test', seed=0.0) psg.add(node_ids=range(10), firing_rate=fr, times=times) assert(psg.populations == ['test']) assert(psg.nodes() == list(range(10))) for i in range(10): spikes = psg.get_times(i) assert(len(spikes) > 0) assert(1.0 < np.min(spikes)) assert(np.max(spikes) < 9.0)
def test_psg_fixed(): psg = PoissonSpikeGenerator(population='test', seed=0.0) psg.add(node_ids=range(10), firing_rate=10.0, times=(0.0, 10.0)) assert(psg.populations == ['test']) assert(psg.nodes() == list(range(10))) time_range = psg.time_range() assert(0 <= time_range[0] < 1.0) assert(9.0 < time_range[1] <= 10.0) # This may fail on certain versions assert(psg.get_times(node_id=5).size > 10) assert(0 < psg.get_times(node_id=8).size < 300) for i in range(10): spikes = psg.get_times(i) assert(np.max(spikes) > 0.1)