def test_run(self): synfire_run.do_run(nNeurons, run_times=run_times, reset=reset, get_all=True) neos = synfire_run.get_output_pop_all_list() spikes_0_0 = neo_convertor.convert_spikes(neos[0], 0) spikes_1_1 = neo_convertor.convert_spikes(neos[1], 1) self.assertEquals(53, len(spikes_0_0)) self.assertEquals(27, len(spikes_1_1)) spike_checker.synfire_spike_checker(spikes_0_0, nNeurons) spike_checker.synfire_spike_checker(spikes_1_1, nNeurons) # v + gsyn_exc + gsyn_ihn = 3 (spikes not in analogsignalarrays if pynn8_syntax: self.assertEquals(3, len(neos[0].segments[0].analogsignalarrays)) self.assertEquals(3, len(neos[1].segments[1].analogsignalarrays)) else: self.assertEquals(3, len(neos[0].segments[0].analogsignals)) self.assertEquals(3, len(neos[1].segments[1].analogsignals)) neo_compare.compare_segments(neos[0].segments[0], neos[1].segments[0]) # neo compare does all the compares so just some safety come once v_0_0 = neo_convertor.convert_data(neos[0], "v", 0) v_1_1 = neo_convertor.convert_data(neos[1], "v", 1) self.assertEquals(nNeurons * run_times[0], len(v_0_0)) self.assertEquals(nNeurons * run_times[1], len(v_1_1)) gsyn_exc_0_0 = neo_convertor.convert_data(neos[0], "gsyn_exc", 0) gsyn_exc_1_1 = neo_convertor.convert_data(neos[1], "gsyn_exc", 1) self.assertEquals(nNeurons * run_times[0], len(gsyn_exc_0_0)) self.assertEquals(nNeurons * run_times[1], len(gsyn_exc_1_1)) gsyn_inh_0_0 = neo_convertor.convert_data(neos[0], "gsyn_inh", 0) gsyn_inh_1_1 = neo_convertor.convert_data(neos[1], "gsyn_inh", 1) self.assertEquals(nNeurons * run_times[0], len(gsyn_inh_0_0)) self.assertEquals(nNeurons * run_times[1], len(gsyn_inh_1_1))
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=runtimes, record=True, record_v=True, record_gsyn_exc=True, record_gsyn_inh=False) spikes_neos = synfire_run.get_output_pop_spikes_list() len0 = reduce(lambda x, y: x + y, map(len, spikes_neos[0].segments[0].spiketrains)) len1 = reduce(lambda x, y: x + y, map(len, spikes_neos[1].segments[0].spiketrains)) len2 = reduce(lambda x, y: x + y, map(len, spikes_neos[2].segments[0].spiketrains)) len3 = reduce(lambda x, y: x + y, map(len, spikes_neos[3].segments[0].spiketrains)) len4 = reduce(lambda x, y: x + y, map(len, spikes_neos[4].segments[0].spiketrains)) self.assertEquals(53, len0) self.assertEquals(106, len1) self.assertEquals(158, len2) self.assertEquals(211, len3) self.assertEquals(263, len4) spikes = map(neo_convertor.convert_spikes, spikes_neos) spike_checker.synfire_spike_checker(spikes, n_neurons)
def do_all_constraint(self): synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], placement_constraint=placement_constraint, record=True, record_7=True, record_v=True, record_v_7=True, record_gsyn_exc=True, record_gsyn_exc_7=True, record_gsyn_inh=False) gsyn_exc = synfire_run.get_output_pop_gsyn_exc_numpy() v = synfire_run.get_output_pop_voltage_numpy() spikes = synfire_run.get_output_pop_spikes_numpy() self.assertEqual(n_neurons * runtime, len(gsyn_exc)) read_gsyn = numpy.loadtxt(gysn_file, delimiter=',') self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc, rtol=1e-04), "gsyn neo method mismatch") self.assertEqual(n_neurons * runtime, len(v)) read_v = numpy.loadtxt(v_file, delimiter=',') self.assertTrue(numpy.allclose(read_v, v, rtol=1e-03), "v neo method mismatch") self.assertEqual(expected_spikes, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) read_spikes = numpy.loadtxt(spike_file, delimiter=',') self.assertTrue(numpy.allclose(read_spikes, spikes), "spikes neo method mismatch")
def test_run(self): results = synfire_npop_run.do_run(nNeurons, n_pops=n_pops, neurons_per_core=neurons_per_core, runtime=runtime) spikes = results self.assertEquals(1666, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons * n_pops)
def test_get_gsyn(self): try: synfire_run.do_run(n_neurons, max_delay=max_delay, time_step=timestep, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], gsyn_path_exc=gsyn_path) spikes = synfire_run.get_output_pop_spikes_numpy() g_syn = synfire_run.get_output_pop_gsyn_exc_numpy() spike_checker.synfire_spike_checker(spikes, n_neurons) try: with open(gsyn_path, "r") as gsyn_file: gsyn2_neo = pickle.load(gsyn_file) gsyn2_numpy = neo_convertor.convert_data(gsyn2_neo, run=0, name="gsyn_exc") self.assertTrue(numpy.allclose(g_syn, gsyn2_numpy)) except UnicodeDecodeError: raise SkipTest( "https://github.com/NeuralEnsemble/python-neo/issues/529") finally: os.remove(gsyn_path) except SpinnmanTimeoutException as ex: # System intentional overload so may error raise SkipTest(ex)
def test_with_constarint(self): synfire_run = TestRun() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, placement_constraint=placement_constraint, delay=delay, run_times=[runtime], record=True, record_v=True, record_gsyn=True) gsyn = synfire_run.get_output_pop_gsyn() v = synfire_run.get_output_pop_voltage() spikes = synfire_run.get_output_pop_spikes() self.assertEquals(n_neurons * runtime, len(gsyn)) read_gsyn = numpy.loadtxt(gysn_file, delimiter=',') self.assertTrue(numpy.allclose(read_gsyn, gsyn)) self.assertEquals(n_neurons * runtime, len(v)) read_v = numpy.loadtxt(v_file, delimiter=',') self.assertTrue(numpy.allclose(read_v, v)) self.assertEquals(expected_spikes, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) read_spikes = numpy.loadtxt(spike_file, delimiter=',') self.assertTrue(numpy.allclose(read_spikes, spikes))
def test_run(self): synfire_run.do_run(nNeurons, delay=delay, neurons_per_core=neurons_per_core, record_v=False, record_gsyn=False) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(333, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_get_gsyn(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(158, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons)
def test_run(self): synfire_run.do_run(nNeurons, record_v=record_v, record_gsyn=record_gsyn) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(53, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_run(self): synfire_run.do_run(nNeurons, run_times=run_times, reset=reset) spikes = synfire_run.get_output_pop_spikes() print spikes self.assertEquals(53, len(spikes[0])) self.assertEquals(27, len(spikes[1])) spike_checker.synfire_spike_checker(spikes[0], nNeurons) spike_checker.synfire_spike_checker(spikes[1], nNeurons)
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=runtimes, extract_between_runs=extract_between_runs) spikes = synfire_run.get_output_pop_spikes() self.assertEqual(158, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons)
def test_run(self): synfire_run.do_run(nNeurons, delay=delay, neurons_per_core=neurons_per_core, record_v=record_v, record_gsyn_exc=record_gsyn, record_gsyn_inh=record_gsyn) spikes = synfire_run.get_output_pop_spikes_numpy() self.assertEqual(333, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_run(self): synfire_run.do_run(nNeurons, run_times=run_times, extract_between_runs=extract_between_runs, reset=reset) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(158, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes() spike_checker.synfire_spike_checker(spikes, n_neurons) if len(spikes) != 263: raise SkipTest(Exception("Unexpected length of spikes"))
def test_run(self): nNeurons = 200 # number of neurons in each population (v, gsyn, spikes) = do_run(nNeurons) spike_checker.synfire_spike_checker(spikes, nNeurons) try: self.assertLess(200, len(spikes)) self.assertGreater(230, len(spikes)) except Exception as ex: # Just in case the range failed raise SkipTest(ex)
def test_run(self): synfire_run.do_run(nNeurons, neurons_per_core=neurons_per_core, delay=delay, run_times=run_times, get_weights=get_weights) spikes = synfire_run.get_output_pop_spikes_numpy() weights = synfire_run.get_weights() self.assertEqual(263, len(spikes)) self.assertEqual(200, len(weights)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_run(self): synfire_run.do_run(nNeurons, spike_times=spike_times, run_times=run_times, reset=reset) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(53, len(spikes[0])) self.assertEquals(261, len(spikes[1])) spike_checker.synfire_spike_checker(spikes[0], nNeurons) spike_checker.synfire_multiple_lines_spike_checker(spikes[1], nNeurons, 2)
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime], seed=self._test_seed) spikes = synfire_run.get_output_pop_spikes_numpy() self.assertEquals(263, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) synfire_run.get_output_pop_gsyn_exc_numpy() synfire_run.get_output_pop_voltage_numpy()
def test_run(self): self.assert_not_spin_three() synfire_run.do_run(nNeurons, run_times=run_times, record_v=record_v, record_gsyn_exc=record_gsyn, record_gsyn_inh=record_gsyn) spikes = synfire_run.get_output_pop_spikes_numpy() self.assertEquals(263, len(spikes)) spike_checker.synfire_spike_checker(spikes, nNeurons)
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, spike_times=spike_times, run_times=runtimes, reset=reset) spikes = synfire_run.get_output_pop_spikes_list_numpy() self.assertEquals(53, len(spikes[0])) self.assertEquals(103, len(spikes[1])) spike_checker.synfire_spike_checker(spikes[0], n_neurons) spike_checker.synfire_multiple_lines_spike_checker(spikes[1], n_neurons, 2)
def test_spikes_no_constarint(self): synfire_run = TestRun() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], record=True, record_v=False, record_gsyn=False) spikes = synfire_run.get_output_pop_spikes() self.assertEquals(expected_spikes, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) read_spikes = numpy.loadtxt(spike_file, delimiter=',') self.assertTrue(numpy.allclose(read_spikes, spikes))
def test_run(self): synfire_run.do_run(nNeurons, spike_times_list=spike_times_list, run_times=run_times) spikes = synfire_run.get_output_pop_spikes_list_numpy() self.assertEquals(53, len(spikes[0])) self.assertEquals(156, len(spikes[1])) spike_checker.synfire_spike_checker(spikes[0], nNeurons) spike_checker.synfire_multiple_lines_spike_checker( spikes[1], nNeurons, 2)
def test_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes() spike_checker.synfire_spike_checker(spikes, n_neurons) try: self.assertLess(240, len(spikes)) self.assertGreater(290, len(spikes)) except Exception as ex: # Just in case the range failed raise SkipTest(ex)
def test_get_gsyn(self): synfire_run.do_run(n_neurons, max_delay=max_delay, time_step=timestep, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes_numpy() gsyn = synfire_run.get_output_pop_gsyn_exc_numpy() self.assertEquals(12, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) gsyn_tools.check_sister_gysn(__file__, n_neurons, runtime, gsyn)
def test_run(self): synfire_run.do_run(nNeurons, spike_times=spike_times, run_times=run_times, reset=reset, new_pop=new_pop) spikes = synfire_run.get_output_pop_spikes_list_numpy() self.assertEquals(53, len(spikes[0])) self.assertEquals(53, len(spikes[1])) spike_checker.synfire_spike_checker(spikes[0], nNeurons) spike_checker.synfire_spike_checker(spikes[1], nNeurons)
def allow(self): try: synfire_run.do_run( n_neurons, time_step=0.1, neurons_per_core=5, delay=1.7, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes_numpy() # no check of spikes length as the system overloads spike_checker.synfire_spike_checker(spikes, n_neurons) # no check of gsyn as the system overloads # System intentional overload so may error except SpinnmanTimeoutException as ex: raise SkipTest() from ex
def do_spikes_no_constraint(self): synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], record=True, record_v=False, record_gsyn_exc_7=False, record_gsyn_inh=False) spikes = synfire_run.get_output_pop_spikes_numpy() self.assertEqual(expected_spikes, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) read_spikes = numpy.loadtxt(spike_file, delimiter=',') self.assertTrue(numpy.allclose(read_spikes, spikes), "spikes neo method mismatch")
def more_runs(self): with LogCapture() as lc: synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes_numpy() # CB Currently eight but could change # Needs to be larger than 1000 timesteps version # Number of auto-pause-resume cycles (7) determined by experiment self.assert_logs_messages( lc.records, "*** Running simulation... ***", 'INFO', 7) self.assertEqual(158, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) synfire_run.get_output_pop_gsyn_exc_numpy() synfire_run.get_output_pop_voltage_numpy()
def test_get_spikes(self): """ test for get spikes """ try: synfire_run.do_run(n_neurons, time_step=timestep, max_delay=max_delay, delay=delay, neurons_per_core=neurons_per_core, run_times=[runtime]) spikes = synfire_run.get_output_pop_spikes_numpy() # Eact spike checking removed as system may oervload spike_checker.synfire_spike_checker(spikes, n_neurons) # System intentional overload so may error except SpinnmanTimeoutException as ex: raise SkipTest(ex)
def test_get_gsyn(self): synfire_run.do_run(n_neurons, max_delay=max_delay, time_step=timestep, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], gsyn_path=gsyn_path) spikes = synfire_run.get_output_pop_spikes() gsyn = synfire_run.get_output_pop_gsyn() self.assertEquals(12, len(spikes)) spike_checker.synfire_spike_checker(spikes, n_neurons) gsyn_tools.check_path_gysn(gsyn_path, n_neurons, runtime, gsyn) os.remove(gsyn_path)