Example #1
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.data")
            current_v_file_path = os.path.join(current_file_path, "v.data")
            current_gsyn_file_path = os.path.join(current_file_path,
                                                  "gsyn.data")
            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=current_gsyn_file_path,
                               v_path=current_v_file_path)

            spikes = synfire_run.get_output_pop_spikes()
            v = synfire_run.get_output_pop_voltage()
            gsyn = synfire_run.get_output_pop_gsyn()

            read_in_spikes = utility_calls.read_spikes_from_file(
                current_spike_file_path, 0, n_neurons, 0, 5000)
            read_in_v = utility_calls.read_in_data_from_file(
                current_v_file_path, 0, n_neurons, 0, 5000)
            read_in_gsyn = utility_calls.read_in_data_from_file(
                current_gsyn_file_path, 0, n_neurons, 0, 5000)

            for spike_element, read_element in zip(spikes, read_in_spikes):
                self.assertEqual(round(spike_element[0], 1),
                                 round(read_element[0], 1))
                self.assertEqual(round(spike_element[1], 1),
                                 round(read_element[1], 1))

            for v_element, read_element in zip(v, read_in_v):
                self.assertEqual(round(v_element[0], 1),
                                 round(read_element[0], 1))
                self.assertEqual(round(v_element[1], 1),
                                 round(read_element[1], 1))

            for gsyn_element, read_element in zip(gsyn, read_in_gsyn):
                self.assertEqual(round(gsyn_element[0], 1),
                                 round(read_element[0], 1))
                self.assertEqual(round(gsyn_element[1], 1),
                                 round(read_element[1], 1))
        except SpinnmanTimeoutException as ex:
            # System sometimes times outs
            raise SkipTest(ex)
Example #2
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 = synfire_run.get_output_pop_voltage()

            read_in_v_values = utility_calls.read_in_data_from_file(
                current_v_file_path, 0, n_neurons, 0, runtime)

            for v_element, read_element in zip(v, read_in_v_values):
                self.assertEqual(round(v_element[0], 1),
                                 round(read_element[0], 1))
                self.assertEqual(round(v_element[1], 1),
                                 round(read_element[1], 1))
                self.assertEqual(round(v_element[2], 1),
                                 round(read_element[2], 1))
            os.remove(current_v_file_path)
            # System intentional overload so may error
        except SpinnmanTimeoutException as ex:
            raise SkipTest(ex)
    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=current_gsyn_file_path,
                           v_path=current_v_file_path,
                           end_before_print=False)
        gsyn = synfire_run.get_output_pop_gsyn()
        v = synfire_run.get_output_pop_voltage()
        spikes = synfire_run.get_output_pop_spikes()

        read_in_spikes = utility_calls.read_spikes_from_file(
            current_spike_file_path, 0, n_neurons, 0, 5000)
        read_in_v = utility_calls.read_in_data_from_file(
            current_v_file_path, 0, n_neurons, 0, 5000)
        read_in_gsyn = utility_calls.read_in_data_from_file(
            current_gsyn_file_path, 0, n_neurons, 0, 5000)

        for spike_element, read_element in zip(spikes, read_in_spikes):
            self.assertEqual(round(spike_element[0], 1),
                             round(read_element[0], 1))
            self.assertEqual(round(spike_element[1], 1),
                             round(read_element[1], 1))

        for v_element, read_element in zip(v, read_in_v):
            self.assertEqual(round(v_element[0], 1), round(read_element[0], 1))
            self.assertEqual(round(v_element[1], 1), round(read_element[1], 1))

        for gsyn_element, read_element in zip(gsyn, read_in_gsyn):
            self.assertEqual(round(gsyn_element[0], 1),
                             round(read_element[0], 1))
            self.assertEqual(round(gsyn_element[1], 1),
                             round(read_element[1], 1))
Example #4
0
def check_path_gysn(path, n_neurons, runtime, gsyn):
    """ Compare an arrays of conductances with baseline data from a file. \
        For testing.

    :param path: A file path.
    :param n_neurons: The number of neurons that produced the data.
    :param runtime: The length of time that the generated data represents.
    :param gsyn: An array of conductances.
    :raise Exception: If the arrays differ.
    """
    gsyn2 = utility_calls.read_in_data_from_file(
        path, 0, n_neurons, 0, runtime, True)
    check_gsyn(gsyn, gsyn2)
    def test_get_voltage(self):
        """
        test that tests the getting 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 = synfire_run.get_output_pop_voltage()

        current_file_path = os.path.dirname(os.path.abspath(__file__))
        current_file_path = os.path.join(current_file_path, "v.data")
        pre_recorded_data = utility_calls.read_in_data_from_file(
            current_file_path, 0, n_neurons, 0, runtime)

        for v_element, read_element in zip(v, pre_recorded_data):
            self.assertAlmostEqual(v_element[0], read_element[0], delta=0.1)
            self.assertAlmostEqual(v_element[1], read_element[1], delta=0.1)
            self.assertAlmostEqual(v_element[2], read_element[2], delta=1)
Example #6
0
def check_path_gysn(path, n_neurons, runtime, gsyn):
    gsyn2 = utility_calls.read_in_data_from_file(path, 0, n_neurons, 0,
                                                 runtime, True)
    check_gsyn(gsyn, gsyn2)
def check_path_gysn(path, n_neurons, runtime, gsyn):
    gsyn2 = utility_calls.read_in_data_from_file(
        path, 0, n_neurons, 0, runtime, True)
    check_gsyn(gsyn, gsyn2)