def test_print_voltage(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        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],
                               v_path=current_v_file_path)
            v_read = synfire_run.get_output_pop_voltage_neo()

            try:
                with open(current_v_file_path, "r") as v_file:
                    v_saved = pickle.load(v_file)
                neo_compare.compare_blocks(v_read, v_saved)
            except UnicodeDecodeError:
                raise SkipTest(
                    "https://github.com/NeuralEnsemble/python-neo/issues/529")
            finally:
                os.remove(current_v_file_path)
            # System intentional overload so may error
        except SpinnmanTimeoutException as ex:
            raise SkipTest(ex)
 def check_data(self, pop, expected_spikes, simtime, early_neo):
     neo = pop.get_data("all")
     spikes = neo.segments[0].spiketrains
     v = neo.segments[0].filter(name="v")[0]
     gsyn_exc = neo.segments[0].filter(name="gsyn_exc")[0]
     for i in range(len(spikes)):
         check_neuron_data(spikes[i], v[:, i], gsyn_exc[:, i],
                           expected_spikes, simtime, pop.label, i)
     neo_compare.compare_blocks(neo, early_neo, same_length=False)
示例#3
0
    def test_va_benchmark(self):

        exc_spikes = do_run(seed=self._test_seed)
        try:
            with open(neo_path, "r") as neo_file:
                recorded_spikes = pickle.load(neo_file)
            neo_compare.compare_blocks(exc_spikes, recorded_spikes)
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")
    def test_print_voltage(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        synfire_run.do_run(n_neurons, max_delay=max_delay, time_step=timestep,
                           neurons_per_core=neurons_per_core, delay=delay,
                           run_times=[runtime], v_path=current_v_file_path)
        v_read = synfire_run.get_output_pop_voltage_neo()

        io = PickleIO(filename=current_v_file_path)
        v_saved = io.read()[0]
        neo_compare.compare_blocks(v_read, v_saved)
        os.remove(current_v_file_path)
示例#5
0
    def test_va_benchmark(self):

        try:
            exc_spikes = do_run()
        # System intentional overload so may error
        except SpinnmanTimeoutException as ex:
            raise SkipTest(ex)
        spike_count = neo_convertor.count_spikes(exc_spikes)
        print(spike_count)
        # CB Jan 14 2019 Result varie between runs
        self.assertLessEqual(2558, spike_count)
        self.assertGreaterEqual(2559, spike_count)
        io = PickleIO(filename=neo_path)
        recorded_spikes = io.read()[0]
        neo_compare.compare_blocks(exc_spikes, recorded_spikes)
示例#6
0
    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_exc=gsyn_path)
        spikes = synfire_run.get_output_pop_spikes_numpy()
        gsyn = synfire_run.get_output_pop_gsyn_exc_neo()

        self.assertEqual(12, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        io = PickleIO(filename=gsyn_path)
        gsyn_saved = io.read()[0]
        neo_compare.compare_blocks(gsyn, gsyn_saved)
        os.remove(gsyn_path)
    def test_va_benchmark(self):

        try:
            exc_spikes = do_run()
        # System intentional overload so may error
        except SpinnmanTimeoutException as ex:
            raise SkipTest(ex)
        spike_count = neo_convertor.count_spikes(exc_spikes)
        self.assertLess(1900, spike_count)
        self.assertGreater(2700, spike_count)
        try:
            with open(neo_path, "r") as neo_file:
                recorded_spikes = pickle.load(neo_file)
            neo_compare.compare_blocks(exc_spikes, recorded_spikes)
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")
    def test_va_benchmark(self):

        exc_spikes = do_run(seed=self._test_seed)
        spike_count = neo_convertor.count_spikes(exc_spikes)
        try:
            self.assertLess(1900, spike_count)
            self.assertGreater(2700, spike_count)
        except Exception as ex:
            # Just in case the range failed
            raise SkipTest(ex)

        try:
            with open(neo_path, "r") as neo_file:
                recorded_spikes = pickle.load(neo_file)
            neo_compare.compare_blocks(exc_spikes, recorded_spikes)
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")
示例#9
0
    def test_script(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        synfire_run.do_run(n_neurons, max_delay=14, time_step=1,
                           neurons_per_core=1, delay=1.7, run_times=[50],
                           spike_path=current_spike_file_path,
                           gsyn_path_exc=current_gsyn_file_path,
                           v_path=current_v_file_path, end_before_print=False)

        spikes_read = synfire_run.get_output_pop_spikes_neo()
        v_read = synfire_run.get_output_pop_voltage_neo()
        gsyn_read = synfire_run.get_output_pop_gsyn_exc_neo()

        try:
            with open(current_spike_file_path, "r") as spike_file:
                spikes_saved = pickle.load(spike_file)
            with open(current_v_file_path, "r") as v_file:
                v_saved = pickle.load(v_file)
            with open(current_gsyn_file_path, "r") as gsyn_file:
                gsyn_saved = pickle.load(gsyn_file)

            neo_compare.compare_blocks(spikes_read, spikes_saved)
            neo_compare.compare_blocks(v_read, v_saved)
            neo_compare.compare_blocks(gsyn_read, gsyn_saved)
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")
    def test_script(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        synfire_run.do_run(n_neurons, max_delay=14, time_step=1,
                           neurons_per_core=1, delay=1.7, run_times=[50],
                           spike_path=current_spike_file_path,
                           gsyn_path_exc=current_gsyn_file_path,
                           v_path=current_v_file_path, end_before_print=False)

        spikes_read = synfire_run.get_output_pop_spikes_neo()
        v_read = synfire_run.get_output_pop_voltage_neo()
        gsyn_read = synfire_run.get_output_pop_gsyn_exc_neo()

        io = PickleIO(filename=current_spike_file_path)
        spikes_saved = io.read()[0]
        io = PickleIO(filename=current_v_file_path)
        v_saved = io.read()[0]
        io = PickleIO(filename=current_gsyn_file_path)
        gsyn_saved = io.read()[0]

        neo_compare.compare_blocks(spikes_read, spikes_saved)
        neo_compare.compare_blocks(v_read, v_saved)
        neo_compare.compare_blocks(gsyn_read, gsyn_saved)
示例#11
0
    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")
示例#12
0
    def test_print_voltage(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        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],
                               v_path=current_v_file_path)
            v_read = synfire_run.get_output_pop_voltage_neo()

            io = PickleIO(filename=current_v_file_path)
            v_saved = io.read()[0]
            neo_compare.compare_blocks(v_read, v_saved)
            os.remove(current_v_file_path)
            # 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_exc=gsyn_path)
        spikes = synfire_run.get_output_pop_spikes_numpy()
        gsyn = synfire_run.get_output_pop_gsyn_exc_neo()

        self.assertEquals(12, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        try:
            with open(gsyn_path, "r") as gsyn_file:
                gsyn_saved = pickle.load(gsyn_file)
            neo_compare.compare_blocks(gsyn, gsyn_saved)
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")
        finally:
            os.remove(gsyn_path)
    def test_print_spikes(self):
        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],
                               spike_path=spike_path)
            spikes = synfire_run.get_output_pop_spikes_neo()

            try:
                with open(spike_path, "r") as spike_file:
                    read_in_spikes = pickle.load(spike_file)

                neo_compare.compare_blocks(spikes, read_in_spikes)
            except UnicodeDecodeError:
                raise SkipTest(
                    "https://github.com/NeuralEnsemble/python-neo/issues/529")

        except SpinnmanTimeoutException as ex:
            # System intentional overload so may error
            raise SkipTest(ex)
    def test_script(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        try:
            n_neurons = 20  # number of neurons in each population
            current_file_path = os.path.dirname(os.path.abspath(__file__))
            current_spike_file_path = os.path.join(current_file_path,
                                                   "spikes.pickle")
            current_v_file_path = os.path.join(current_file_path, "v.pickle")
            current_gsyn_file_path = os.path.join(current_file_path,
                                                  "gsyn.pickle")
            synfire_run.do_run(n_neurons,
                               max_delay=14,
                               time_step=0.1,
                               neurons_per_core=1,
                               delay=1.7,
                               run_times=[50],
                               spike_path=current_spike_file_path,
                               gsyn_path_exc=current_gsyn_file_path,
                               v_path=current_v_file_path)

            spikes_read = synfire_run.get_output_pop_spikes_neo()
            v_read = synfire_run.get_output_pop_voltage_neo()
            gsyn_read = synfire_run.get_output_pop_gsyn_exc_neo()

            try:
                with open(current_spike_file_path, "r") as spike_file:
                    spikes_saved = pickle.load(spike_file)
                with open(current_v_file_path, "r") as v_file:
                    v_saved = pickle.load(v_file)
                with open(current_gsyn_file_path, "r") as gsyn_file:
                    gsyn_saved = pickle.load(gsyn_file)

                neo_compare.compare_blocks(spikes_read, spikes_saved)
                neo_compare.compare_blocks(v_read, v_saved)
                neo_compare.compare_blocks(gsyn_read, gsyn_saved)
            except UnicodeDecodeError:
                raise SkipTest(
                    "https://github.com/NeuralEnsemble/python-neo/issues/529")

        except SpinnmanTimeoutException as ex:
            # System sometimes times outs
            raise SkipTest(ex)
示例#16
0
    def test_script(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        try:
            n_neurons = 20  # number of neurons in each population
            current_file_path = os.path.dirname(os.path.abspath(__file__))
            current_spike_file_path = os.path.join(current_file_path,
                                                   "spikes.pickle")
            current_v_file_path = os.path.join(current_file_path, "v.pickle")
            current_gsyn_file_path = os.path.join(current_file_path,
                                                  "gsyn.pickle")
            synfire_run.do_run(n_neurons, max_delay=14, time_step=0.1,
                               neurons_per_core=1, delay=1.7, run_times=[50],
                               spike_path=current_spike_file_path,
                               gsyn_path_exc=current_gsyn_file_path,
                               v_path=current_v_file_path)

            spikes_read = synfire_run.get_output_pop_spikes_neo()
            v_read = synfire_run.get_output_pop_voltage_neo()
            gsyn_read = synfire_run.get_output_pop_gsyn_exc_neo()

            io = PickleIO(filename=current_spike_file_path)
            spikes_saved = io.read()[0]
            io = PickleIO(filename=current_v_file_path)
            v_saved = io.read()[0]
            io = PickleIO(filename=current_gsyn_file_path)
            gsyn_saved = io.read()[0]

            neo_compare.compare_blocks(spikes_read, spikes_saved)
            neo_compare.compare_blocks(v_read, v_saved)
            neo_compare.compare_blocks(gsyn_read, gsyn_saved)

        except SpinnmanTimeoutException as ex:
            # System sometimes times outs
            raise SkipTest(ex)