Пример #1
0
    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")
Пример #2
0
    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")
Пример #3
0
    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")
Пример #4
0
    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]))
Пример #5
0
    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")
Пример #6
0
    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")
Пример #7
0
                           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()