def do_v_no_constraint(self): synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], record=False, record_v=True, record_gsyn_exc_7=False, record_gsyn_inh=False) v = synfire_run.get_output_pop_voltage_numpy() 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")
def do_gsyn_no_constraint(self): synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, delay=delay, run_times=[runtime], record=False, record_v=False, record_gsyn_exc_7=True, record_gsyn_inh=False) gsyn_exc = synfire_run.get_output_pop_gsyn_exc_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")
def do_all_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_7=True, record_v=True, record_v_7=True, record_gsyn_exc=True, record_gsyn_exc_7=True, record_gsyn_inh=False) gsyn_exc_7 = synfire_run.get_output_pop_gsyn_exc_7() v_7 = synfire_run.get_output_pop_voltage_7() spikes_7 = synfire_run.get_output_pop_spikes_7() 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=',') if not numpy.allclose(read_gsyn, gsyn_exc_7): for g1, g2 in zip(read_gsyn, gsyn_exc_7): if not numpy.allclose(g1, g2, rtol=1e-04): print(g1, g2, g1[2] - g2[2], (g1[2] - g2[2]) / g1[2]) self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc_7, rtol=1e-04), "gsyn synakker method mismatch") 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_7, rtol=1e-03), "v synakker method mismatch") 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_7), "spikes synakker method mismatch") self.assertTrue(numpy.allclose(read_spikes, spikes), "spikes neo method mismatch")
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 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 get_before_and_after(self): synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, weight_to_spike=weight_to_spike, delay=delay, placement_constraint=placement_constraint, run_times=runtimes, get_weights=get_weights, get_delays=get_delays) weights = synfire_run.get_weights() self.assertEqual(n_neurons, len(weights[0])) self.assertEqual(n_neurons, len(weights[1])) self.assertTrue(numpy.allclose(weights[0][0][2], weights[1][0][2])) delays = synfire_run.get_delay() self.assertEqual(n_neurons, len(delays[0])) self.assertEqual(n_neurons, len(delays[1])) self.assertTrue(numpy.allclose(delays[0][0][2], delays[1][0][2]))
record_v=False, record_gsyn_exc_7=True, record_gsyn_inh=False) gsyn_exc = synfire_run.get_output_pop_gsyn_exc_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") def test_gsyn_no_constraint(self): self.runsafe(self.do_gsyn_no_constraint) if __name__ == '__main__': 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() gsyn_exc_neo = synfire_run.get_output_pop_gsyn_exc_neo()
# along with this program. If not, see <http://www.gnu.org/licenses/>. """ Synfirechain-like example """ import unittest from testfixtures import LogCapture import spynnaker.plot_utils as plot_utils import spynnaker.spike_checker as spike_checker from spinnaker_testbase import BaseTestCase from spynnaker_integration_tests.scripts import SynfireRunner n_neurons = 200 # number of neurons in each population runtime = 3000 neurons_per_core = 43 synfire_run = SynfireRunner() class TestVeryLow(BaseTestCase): """ tests the run is split buy auto pause resume """ @unittest.skip("does not work with this size for purely the java. Python " "is fine. Needs investigating.") def test_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
from spinnaker_testbase import BaseTestCase from spynnaker_integration_tests.scripts import SynfireRunner from spinn_front_end_common.utilities.globals_variables import ( provenance_file_path, report_default_directory) from spinn_front_end_common.utilities.report_functions import EnergyReport import sqlite3 n_neurons = 200 # number of neurons in each population neurons_per_core = n_neurons / 2 run_times = [5000] # parameters for population 1 first run input_class = p.SpikeSourcePoisson start_time = 0 duration = 5000.0 rate = 2.0 synfire_run = SynfireRunner() class TestPowerMonitoring(BaseTestCase): def query_provenance(self, query, *args): prov_file = os.path.join(provenance_file_path(), "provenance.sqlite3") with sqlite3.connect(prov_file) as prov_db: prov_db.row_factory = sqlite3.Row return list(prov_db.execute(query, args)) def do_run(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=run_times, input_class=input_class, start_time=start_time,
weights = synfire_run.get_weights() self.assertEqual(n_neurons, len(weights[0])) self.assertEqual(n_neurons, len(weights[1])) self.assertTrue(numpy.allclose(weights[0][0][2], weights[1][0][2])) delays = synfire_run.get_delay() self.assertEqual(n_neurons, len(delays[0])) self.assertEqual(n_neurons, len(delays[1])) self.assertTrue(numpy.allclose(delays[0][0][2], delays[1][0][2])) def test_get_before_and_after(self): self.runsafe(self.get_before_and_after) if __name__ == '__main__': synfire_run = SynfireRunner() synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, weight_to_spike=weight_to_spike, delay=delay, placement_constraint=placement_constraint, run_times=runtimes, get_weights=get_weights, get_delays=get_delays) weights = synfire_run.get_weights() delays = synfire_run.get_delay() print("weights[0]") print(weights[0]) print(weights[0].shape) print("weights[1]") print(weights[1]) print(weights[1].shape) print("delays[0]") print(delays[0])
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ Synfirechain-like example """ import pytest from spinnaker_testbase import BaseTestCase from spynnaker_integration_tests.scripts import SynfireRunner from pacman.exceptions import PacmanException n_neurons = 200 # number of neurons in each population runtime = 3000 neurons_per_core = 1 synfire_run = SynfireRunner() class TestTooLow(BaseTestCase): """ tests the run fails due to too small ram """ def test_too_low(self): with pytest.raises(PacmanException): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=[runtime]) if __name__ == '__main__': synfire_run.do_run(n_neurons,
from spynnaker_integration_tests.scripts import SynfireRunner n_neurons = 200 # number of neurons in each population neurons_per_core = n_neurons / 2 run_times = [5000, 5000] # parameters for population 1 first run input_class = p.SpikeSourcePoisson start_time = 0 duration = 5000.0 rate = 2.0 # parameters for population 2 first run set_between_runs = [(1, 'start', 5000), (1, 'rate', 200.0), (1, 'duration', 2000.0)] extract_between_runs = False synfire_run = SynfireRunner() class TestSynfirePoissonIfCurrExpParameter(BaseTestCase): def synfire_poisson_if_curr_exp_parameter(self): synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core, run_times=run_times, input_class=input_class, start_time=start_time, duration=duration, rate=rate, extract_between_runs=extract_between_runs, set_between_runs=set_between_runs, seed=12345) spikes = synfire_run.get_output_pop_spikes_numpy()