def test_thrtytwo(self): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100) pop_1 = sim.Population(40, sim.IF_curr_exp(), label="pop_1") input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(input, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) # A range of 32 was problematic # due to the need for one more index to point none recording at pop_1[0:32].record(["spikes", "v"]) simtime = 10 sim.run(simtime) neo = pop_1.get_data(variables=["spikes", "v"]) # pylint: disable=no-member spikes = neo.segments[0].spiketrains # Include all the spiketrains as there is no outside index self.assertEqual(40, len(spikes)) for i in range(32): self.assertEqual(1, len(spikes[i])) for i in range(32, 40): self.assertEqual(0, len(spikes[i])) v = neo.segments[0].filter(name='v')[0] self.assertEqual(32, len(v.channel_index.index)) self.assertEqual(32, len(v[0])) sim.end()
def do_run(): sim.setup(1.0) simulator = get_simulator() simulator._xml_paths.append( os.path.join(os.path.dirname(test_master_pop.__file__), "algorithms.xml")) # Break up the pre population as that is where delays happen sim.set_number_of_neurons_per_core(sim.SpikeSourceArray, 50) pop1 = sim.Population(100, sim.SpikeSourceArray([1]), label="pop1") pop2 = sim.Population(10, sim.IF_curr_exp(), label="pop2") pop2.record("spikes") # Choose to use delay extensions synapse_type = sim.StaticSynapse(weight=0.5, delay=17) conn = sim.FixedNumberPreConnector(10) projection = sim.Projection(pop1, pop2, conn, synapse_type=synapse_type) delays = projection.get(["delay"], "list") sim.run(30) # There are 100 connections, as there are 10 for each post-neuron assert (len(delays) == 100) # If the delays are done right, all pre-spikes should arrive at the # same time causing each neuron in the post-population to spike spikes = pop2.get_data("spikes").segments[0].spiketrains for s in spikes: assert (len(s) == 1) sim.end()
def do_run(self): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100) input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") pop_1 = sim.Population(200, sim.IF_curr_exp(), label="pop_1") sim.Projection(input, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=18)) sim.run(500) provenance_files = self.get_provenance_files() sim.end() # extract_iobuf_from_cores = 0,0,1 self.assertIn("iobuf_for_chip_0_0_processor_id_1.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_2.txt", provenance_files) self.assertIn("iobuf_for_chip_0_0_processor_id_3.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_4.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_5.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_6.txt", provenance_files) self.assertIn("iobuf_for_chip_1_1_processor_id_1.txt", provenance_files)
def multi_board_spike_output(self): self.assert_not_spin_three() TestMultiBoardSpikeOutput.counts = dict() p.setup(1.0, n_chips_required=((48 * 2) + 1)) machine = p.get_machine() labels = list() pops = list() for chip in machine.ethernet_connected_chips: # print("Adding population on {}, {}".format(chip.x, chip.y)) label = "{}, {}".format(chip.x, chip.y) spike_cells = {"spike_times": [i for i in range(100)]} pop = p.Population(10, p.SpikeSourceArray(**spike_cells), label=label) pop.add_placement_constraint(chip.x, chip.y) labels.append(label) pops.append(pop) TestMultiBoardSpikeOutput.counts[label] = 0 live_output = p.external_devices.SpynnakerLiveSpikesConnection( receive_labels=labels, local_port=None) for label, pop in zip(labels, pops): p.external_devices.activate_live_output_for( pop, database_notify_port_num=live_output.local_port) live_output.add_receive_callback( label, TestMultiBoardSpikeOutput.spike_receiver) p.run(1000) p.end() for label in labels: # print("Received {} of 1000 spikes from {}".format( # TestMultiBoardSpikeOutput.counts[label], label)) self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
def do_run(): p.setup(timestep=1, min_delay=1) spiker = p.Population(1, p.SpikeSourceArray(spike_times=[[0]]), label='inputSSA_1') if_pop = p.Population(2, p.IF_cond_exp(), label='pop_1') if_pop.record("spikes") if_pop.record("v") p.Projection(spiker, if_pop, p.OneToOneConnector(), synapse_type=p.StaticSynapse(weight=5.0, delay=1), receptor_type="excitatory", source=None, space=None) p.run(30) all1 = if_pop.get_data(["spikes", "v"]) p.reset() p.run(30) all2 = if_pop.get_data(["spikes", "v"]) p.end() return (all1, all2)
def record_v(self): sim.setup(timestep=1) simtime = 100 input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0, 30]), label="input") pop = sim.Population(32, sim.IF_curr_exp(), label="pop") sim.Projection(input, pop, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) pop.record("v") sim.run(simtime) neo = pop.get_data("all") pop.write_data(pickle_path, "all") io = PickleIO(filename=pickle_path) saved = io.read()[0] neo_compare.compare_blocks(neo, saved) assert len(neo.segments[0].spiketrains) == 0 assert len(neo.segments[0].filter(name="v")) > 0 assert len(neo.segments[0].filter(name="gsyn_exc")) == 0 v_neo = pop.get_data("v") pop.write_data(pickle_path, "v") io = PickleIO(filename=pickle_path) v_saved = io.read()[0] neo_compare.compare_blocks(v_neo, v_saved) neo_compare.compare_blocks(v_neo, neo) with self.assertRaises(ConfigurationException): pop.get_data("spikes") with self.assertRaises(ConfigurationException): pop.get_data("gsyn_exc") with self.assertRaises(ConfigurationException): pop.write_data(pickle_path, "spikes") with self.assertRaises(ConfigurationException): pop.write_data(pickle_path, "gsyn_exc")
def test_stepped(): ############################################################ # Start the external sender # ############################################################ stepped = subprocess.Popen(binary_path("stepped_receiver"), stderr=subprocess.PIPE) firstline = str(stepped.stderr.readline(), "UTF-8") match = re.match("^Listening on (.*)$", firstline) if not match: receiver.kill() raise Exception(f"Stepped returned unknown output: {firstline}") stepped_port = int(match.group(1)) p.setup(1.0) pop = p.Population(100, p.SpikeSourceArray([[i] for i in range(100)]), label="ssa") p.external_devices.activate_live_output_for( pop, database_notify_port_num=stepped_port) p.external_devices.run_sync(100, 20) p.end() last_line = str(stepped.stderr.readline(), "UTF-8") print(last_line) print("Waiting for stepped to stop...") stepped.wait() print("Done") # Check spike count, assuming some might get lost match = re.match("^Received (.*) spikes$", last_line) assert (match) assert (50 <= int(match.group(1)) <= 100)
def run_script(): n_neurons = 500 simtime = SIMTIME sim.setup(timestep=1) pop_1 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_1") input1 = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(input1, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) input2 = sim.Population(n_neurons, sim.SpikeSourcePoisson(rate=100.0, seed=1), label="Stim_Exc") sim.Projection(input2, pop_1, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) pop_1.record(['spikes', 'v', 'gsyn_exc', 'gsyn_inh']) sim.run(simtime) neo = pop_1.get_data() spikes = neo.segments[0].spiketrains v = neo.segments[0].filter(name='v')[0] exc = neo.segments[0].filter(name='gsyn_exc')[0] inh = neo.segments[0].filter(name='gsyn_inh')[0] sim.end() return spikes, v, exc, inh
def do_run(self): sources = 300 destinations = 300 aslist = [] spiketimes = [] for s in range(sources): for d in range(destinations): aslist.append((s, d, 5 + random.random(), random.randint(1, 5))) spiketimes.append([s * 20]) sim.setup(1.0) pop1 = sim.Population(sources, sim.SpikeSourceArray(spike_times=spiketimes), label="input") pop2 = sim.Population(destinations, sim.IF_curr_exp(), label="pop2") synapse_type = sim.StaticSynapse(weight=5, delay=2) projection = sim.Projection(pop1, pop2, sim.FromListConnector(aslist), synapse_type=synapse_type) pop2.record("spikes") sim.run(sources * 20) from_pro = projection.get(["weight", "delay"], "list") self.assertEqual(sources * destinations, len(from_pro)) spikes = pop2.spinnaker_get_data("spikes") self.assertEqual(sources * destinations, len(spikes)) sim.end()
def setup(self): sim.setup(timestep=1.0, n_boards_required=self.n_boards) try: machine = sim.get_machine() except ConfigurationException as oops: if "Failure to detect machine " in str(oops): raise SkipTest( "You Need at least {} boards to run this test".format( self.n_boards)) from oops raise oops input_spikes = list(range(0, self.simtime - 100, 10)) self._expected_spikes = len(input_spikes) input = sim.Population(1, sim.SpikeSourceArray(spike_times=input_spikes), label="input") self._pops = [] for i, chip in enumerate(machine.ethernet_connected_chips): if i >= self.n_boards: break offset = machine.BOARD_48_CHIPS[i % 48] x = chip.x + offset[0] y = chip.y + offset[1] # safety code in case there is a hole in the board if not machine.is_chip_at(x, y): x = chip.x y = chip.y self._pops.append(self.add_pop(x, y, self.n_neurons, input))
def do_run(self): sim.setup(timestep=1.0, n_boards_required=1) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100) machine = globals_variables.get_simulator().machine input1 = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input1") input2 = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input2") input3 = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input3") input4 = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input4") # Make sure there is stuff at the cores specified in the cfg file input1.set_constraint(ChipAndCoreConstraint(0, 0, 1)) input2.set_constraint(ChipAndCoreConstraint(0, 0, 3)) # While there must be a chip 0,0 chip 1,1 could be missing if machine.is_chip_at(1, 1): input3.set_constraint(ChipAndCoreConstraint(1, 1, 1)) # Make sure there is stuff at a core not specified in the cfg file input4.set_constraint(ChipAndCoreConstraint(0, 0, 2)) sim.run(500) provenance_files = self.get_app_iobuf_files() sim.end() self.assertIn("iobuf_for_chip_0_0_processor_id_1.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_2.txt", provenance_files) self.assertIn("iobuf_for_chip_0_0_processor_id_3.txt", provenance_files) self.assertNotIn("iobuf_for_chip_0_0_processor_id_4.txt", provenance_files) if machine.is_chip_at(1, 1): self.assertIn("iobuf_for_chip_1_1_processor_id_1.txt", provenance_files) self.assertNotIn("iobuf_for_chip_1_1_processor_id_2.txt", provenance_files)
def test_no_init(self): sim.setup(timestep=1.0) pop = sim.Population(4, sim.SpikeSourceArray()) with pytest.raises(KeyError): pop.initialize(v="Anything") with pytest.raises(KeyError): _ = pop.initial_values sim.end()
def do_run(): """ test that tests the printing of v from a pre determined recording :return: """ p.setup(timestep=0.04, min_delay=1.0, max_delay=4.0) n_neurons = 128 * 128 # number of neurons in each population p.set_number_of_neurons_per_core(p.IF_cond_exp, 256) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0, 'e_rev_E': 0., 'e_rev_I': -80. } populations = list() projections = list() weight_to_spike = 0.035 delay = 1.7 current_file_path = os.path.dirname(os.path.abspath(__file__)) spikes_file = os.path.join(current_file_path, 'test.spikes') spikes = read_spikefile(spikes_file, n_neurons) populations.append( p.Population(n_neurons, p.SpikeSourceArray(spike_times=spikes), label='inputSpikes_1')) populations.append( p.Population(n_neurons, p.IF_cond_exp(**cell_params_lif), label='pop_1')) projections.append( p.Projection(populations[0], populations[1], p.OneToOneConnector(), synapse_type=p.StaticSynapse(weight=weight_to_spike, delay=delay))) populations[1].record("spikes") p.run(1000) spikes = populations[1].get_data("spikes") p.end() return spikes
def live_neuron_voltage(): p.setup(1.0) run_time = 1000.0 create_edges = False time_1 = 10 key_1 = 0x1 devices_1 = [Device(key_1, time_1, "DEVICE_1")] translator_1 = Translator(devices_1) model_1 = p.external_devices.ExternalDeviceLifControl( devices_1, create_edges, translator_1) time_2_1 = 5 key_2_1 = 0xE time_2_2 = 3 key_2_2 = 0xF devices_2 = [ Device(key_2_1, time_2_1, "DEVICE_1"), Device(key_2_2, time_2_2, "DEVICE_2") ] translator_2 = Translator(devices_2) model_2 = p.external_devices.ExternalDeviceLifControl( devices_2, create_edges, translator_2) conn = p.external_devices.SpynnakerLiveSpikesConnection( receive_labels=["stim"], local_port=None) conn.add_receive_callback("stim", spike_receiver) stim = p.Population(1, p.SpikeSourceArray(range(0, 1000, 100)), label="stim") p.external_devices.activate_live_output_for( stim, database_notify_port_num=conn.local_port) ext_pop = p.external_devices.EthernetControlPopulation( len(devices_1), model_1) ext_pop.record(["v"]) ext_pop_2 = p.external_devices.EthernetControlPopulation( len(devices_2), model_2) ext_pop_2.record(["v"]) p.Projection(stim, ext_pop, p.OneToOneConnector(), p.StaticSynapse(1.0, 1.0)) p.run(run_time) v = ext_pop.get_data("v").segments[0].analogsignals[0].as_array()[:, 0] p.end() relevant_v = v[1:1000:time_1] print(v) print(relevant_v) print(len(translator_1.voltages[key_1]), translator_1.voltages[key_1]) print(len(translator_2.voltages[key_2_1]), translator_2.voltages[key_2_1]) print(len(translator_2.voltages[key_2_2]), translator_2.voltages[key_2_2]) assert (len(translator_1.voltages[key_1]) >= (run_time // time_1) // 2) assert (len(translator_2.voltages[key_2_1]) >= (run_time // time_2_1) // 2) assert (len(translator_2.voltages[key_2_2]) >= (run_time // time_2_2) // 2) assert (numpy.sum(translator_2.voltages[key_2_1]) == 0) assert (numpy.sum(translator_2.voltages[key_2_2]) == 0) i = 0 for volts in translator_1.voltages[key_1]: while i < len(relevant_v) and volts != relevant_v[i]: i += 1 assert (i < len(relevant_v))
def onetoone_population_views(self): sim.setup(timestep=1.0) in_pop = sim.Population(4, sim.SpikeSourceArray([0]), label="in_pop") pop = sim.Population(4, sim.IF_curr_exp(), label="pop") conn = sim.Projection(in_pop[1:3], pop[2:4], sim.OneToOneConnector(), sim.StaticSynapse(weight=0.5, delay=2)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() target = [[1, 2, 0.5, 2.], [2, 3, 0.5, 2.]] self.assertCountEqual(weights, target)
def __init__(self, dvs_input, sim_t, w_kc2kc=0): self.w_kc2kc = w_kc2kc self.sim_t = sim_t self.pn_neuron_idx = range(0, nb_pn, nb_pn / 5) self.kc_neuron_idx = range(0, nb_kc, nb_kc / 10) self.spike_source = sim.Population( nb_pn, sim.SpikeSourceArray(spike_times=dvs_input), label="DVS") self.pns = sim.Population(nb_pn, model(**cell_params), label="PN") self.kcs = sim.Population(nb_kc, model(**cell_params), label="KC") self.kcs_a = sim.Population(nb_kc, model(**cell_params), label="KC_A") self.ens = sim.Population(nb_en, model(**cell_params), label="EN") self.ens_a = sim.Population(nb_en, model(**cell_params), label="EN_A") self.dvs2pn = sim.Projection(self.spike_source, self.pns, sim.OneToOneConnector(), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.pn2kc = sim.Projection(self.pns, self.kcs, sim.FixedTotalNumberConnector(nb_pn2kc * nb_kc), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.pn2kc_a = sim.Projection(self.pns, self.kcs_a, sim.FixedTotalNumberConnector(nb_pn2kc * nb_kc), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.kc2en = sim.Projection(self.kcs, self.ens, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.15, delay=1.0), receptor_type='excitatory') self.kc_a2en_a = sim.Projection(self.kcs_a, self.ens_a, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.15, delay=1.0), receptor_type='excitatory') self.kc_a2kc_a = sim.Projection(self.kcs, self.kcs_a, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.1, delay=1.0), receptor_type='excitatory') self.ens.record(['v', 'spikes']) self.ens_a.record(['v', 'spikes'])
def do_run(self): p.setup(timestep=1, min_delay=1, max_delay=15) population = p.Population(1, p.SpikeSourceArray(spike_times=[[0]]), label='inputSSA_1') population.record("all") p.run(30) population.get_data("all") p.end()
def test_set_spikes(self): sim.setup(timestep=1) if_curr = sim.Population(1, sim.IF_curr_exp()) self.assertListEq([], if_curr._get_all_recording_variables()) ssa = sim.Population( 1, sim.SpikeSourceArray(spike_times=[0])) ssp = sim.Population(2, sim.SpikeSourcePoisson(rate=100.0, seed=1)) if_curr.record("spikes") self.assertListEq(["spikes"], if_curr._get_all_recording_variables()) ssa.record("spikes") ssp.record("spikes") sim.end()
def test_set_spikes_indexes(self): sim.setup(timestep=1) if_curr = sim.Population(5, sim.IF_curr_exp()) recorder = if_curr._vertex._neuron_recorder ssa = sim.Population( 5, sim.SpikeSourceArray(spike_times=[0])) ssp = sim.Population(5, sim.SpikeSourcePoisson(rate=100.0, seed=1)) if_curr.record("spikes", indexes=[1, 2, 4]) ssa.record("spikes", indexes=[1, 2, 4]) ssp.record("spikes", indexes=[1, 2, 4]) self.assertListEq(["spikes"], if_curr._get_all_recording_variables()) assert recorder._indexes["spikes"] == [1, 2, 4]
def using_population_views(self): sim.setup(timestep=1.0) input = sim.Population(4, sim.SpikeSourceArray([0]), label="input") pop = sim.Population(4, sim.IF_curr_exp(), label="pop") conn = sim.Projection(input[1:3], pop[2:4], sim.AllToAllConnector(), sim.StaticSynapse(weight=0.5, delay=2)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() target = [(1, 2, 0.5, 2.), (1, 3, 0.5, 2.), (2, 2, 0.5, 2.), (2, 3, 0.5, 2.)] self.assertEqual(weights.tolist(), target)
def test_set_spikes_interval(self): sim.setup(timestep=1) if_curr = sim.Population(1, sim.IF_curr_exp()) recorder = if_curr._vertex._neuron_recorder self.assertListEq([], if_curr._get_all_recording_variables()) ssa = sim.Population( 1, sim.SpikeSourceArray(spike_times=[0])) ssp = sim.Population(2, sim.SpikeSourcePoisson(rate=100.0, seed=1)) if_curr.record("spikes", sampling_interval=2) ssa.record("spikes", sampling_interval=2) ssp.record("spikes", sampling_interval=2) self.assertListEq(["spikes"], if_curr._get_all_recording_variables()) assert recorder.get_neuron_sampling_interval("spikes") == 2
def run_network(timestep, steps_per_timestep): p.setup(timestep, max_delay=1.0) pre = p.Population(1, p.SpikeSourceArray(range(0, 100, 10))) post = p.Population(1, p.IF_cond_exp(), additional_parameters={ "n_steps_per_timestep": steps_per_timestep}) post.record(["v", "spikes"]) p.Projection(pre, post, p.AllToAllConnector(), p.StaticSynapse(weight=0.13)) p.run(100) v = post.get_data("v").segments[0].filter(name='v')[0] spikes = post.get_data("spikes").segments[0].spiketrains p.end() return v, spikes
def simple_script(self): # A simple script that should work whatever we do, but only if the # SDRAM is worked out correctly! p.setup(1.0) src = p.Population(1, p.SpikeSourceArray([50, 150]), label="input_pop") pop = p.Population(1, p.IF_curr_exp(), label="neuron") p.Projection( src, pop, p.OneToOneConnector(), synapse_type=p.StaticSynapse(weight=1.0)) src.record('spikes') pop.record("all") p.run(200) p.end()
def testReset_add(self): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 1) input = sim.Population( 1, sim.SpikeSourceArray(spike_times=[0]), label="input") pop_1 = sim.Population(2, sim.IF_curr_exp(), label="pop_1") sim.Projection(input, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) sim.run(10) sim.Population(2, sim.IF_curr_exp(), label="pop_2") with self.assertRaises(NotImplementedError): sim.run(10)
def using_static_synapse_singles(self): sim.setup(timestep=1.0) input = sim.Population(2, sim.SpikeSourceArray([0]), label="input") pop = sim.Population(2, sim.IF_curr_exp(), label="pop") conn = sim.Projection(input, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.7, delay=3)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() target = [(0, 0, 0.7, 3), (0, 1, 3, 33), (1, 0, 0.4, 12), (1, 1, 0.5, 21)] for i in range(2): for j in range(2): self.assertAlmostEqual(weights[i][j], target[i][j], places=3)
def fixedprob_population_views(self): sim.setup(timestep=1.0) in_pop = sim.Population(4, sim.SpikeSourceArray([0]), label="in_pop") pop = sim.Population(4, sim.IF_curr_exp(), label="pop") rng = NumpyRNG(seed=1) conn = sim.Projection(in_pop[1:3], pop[2:4], sim.FixedProbabilityConnector(0.5, rng=rng), sim.StaticSynapse(weight=0.5, delay=2)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() # The fixed seed means this gives the same answer each time target = [[1, 3, 0.5, 2.], [2, 2, 0.5, 2.], [2, 3, 0.5, 2]] self.assertCountEqual(weights, target)
def test_set_spikes_indexes(self): sim.setup(timestep=1) if_curr = sim.Population(5, sim.IF_curr_exp()) recorder = if_curr._vertex.neuron_recorder ssa = sim.Population(5, sim.SpikeSourceArray(spike_times=[0])) ssp = sim.Population(5, sim.SpikeSourcePoisson(rate=100.0), additional_parameters={"seed": 1}) if_curr[1, 2, 4].record("spikes") ssa[1, 2, 4].record("spikes") ssp[1, 2, 4].record("spikes") self.assertCountEqual(["spikes"], if_curr._recorder.get_all_recording_variables()) assert recorder._indexes["spikes"] == [1, 2, 4]
def test_cause_error(self): with self.assertRaises(ConfigurationException): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100) pop_1 = sim.Population(1, sim.IF_curr_exp(), label="pop_1") input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(input, pop_1, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) simtime = 10 sim.run(simtime) pop_1.get_data(variables=["v"])
def do_run(self): with LogCapture() as lc: sim.setup(1.0) pop = sim.Population(1, sim.IF_curr_exp, {}, label="pop") inp = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(inp, pop, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=5)) sim.run(10) self.assert_logs_messages(lc.records, "Working out if machine is booted", 'INFO', 1)
def test_set_all(self): sim.setup(timestep=1) if_curr = sim.Population(1, sim.IF_curr_exp()) ssa = sim.Population(1, sim.SpikeSourceArray(spike_times=[0])) ssp = sim.Population(2, sim.SpikeSourcePoisson(rate=100.0), additional_parameters={"seed": 1}) if_curr.record("all") self.assertListEq(["spikes", "v", "gsyn_inh", "gsyn_exc"], if_curr._get_all_recording_variables()) ssa.record("all") self.assertListEq(["spikes"], ssa._get_all_recording_variables()) ssp.record("all") self.assertListEq(["spikes"], ssp._get_all_recording_variables()) sim.end()