Exemplo n.º 1
0
    def test_preprocess(self):
        self.features = GeneralSpikingFeatures(logger_level="error")

        time, spikes, info = self.features.preprocess(self.time, self.values, self.info)

        self.assertEqual(spikes.nr_spikes, 12)

        self.assertIsInstance(spikes, Spikes)
        self.assertTrue(np.array_equal(self.time, time))
Exemplo n.º 2
0
    def test_preprocess_normalize(self):
        self.features = GeneralSpikingFeatures(logger_level="error", normalize=True, threshold=0.4, end_threshold=-0.1)

        time, spikes, info = self.features.preprocess(self.time, self.values, self.info)

        self.assertEqual(spikes.nr_spikes, 12)

        self.assertIsInstance(spikes, Spikes)
        self.assertTrue(np.array_equal(self.time, time))
        self.assertTrue(spikes[0].V_spike > 1)
Exemplo n.º 3
0
class TestGeneralSpikingFeatures(unittest.TestCase):
    def setUp(self):
        folder = os.path.dirname(os.path.realpath(__file__))

        self.time = np.load(os.path.join(folder, "data/t_test.npy"))
        self.values = np.load(os.path.join(folder, "data/U_test.npy"))
        self.info = {"info": 1}

    def test_initNone(self):
        self.features = GeneralSpikingFeatures(logger_level="error")

        self.assertIsInstance(self.features, GeneralSpikingFeatures)
        self.assertIsNone(self.features.spikes)
        self.assertIn("calculate_spikes", self.features.utility_methods)

    def test_calculate_spikes(self):
        self.features = GeneralSpikingFeatures(logger_level="error")

        spikes = self.features.calculate_spikes(self.time, self.values)

        self.assertEqual(spikes.nr_spikes, 12)

    def test_preprocess(self):
        self.features = GeneralSpikingFeatures(logger_level="error")

        time, spikes, info = self.features.preprocess(self.time, self.values,
                                                      self.info)

        self.assertEqual(spikes.nr_spikes, 12)

        self.assertIsInstance(spikes, Spikes)
        self.assertTrue(np.array_equal(self.time, time))

    def test_preprocess_normalize(self):
        self.features = GeneralSpikingFeatures(logger_level="error",
                                               normalize=True,
                                               threshold=0.4,
                                               end_threshold=-0.1)

        time, spikes, info = self.features.preprocess(self.time, self.values,
                                                      self.info)

        self.assertEqual(spikes.nr_spikes, 12)

        self.assertIsInstance(spikes, Spikes)
        self.assertTrue(np.array_equal(self.time, time))
        self.assertTrue(spikes[0].V_spike > 1)

    def test_reference_feature(self):
        self.features = GeneralSpikingFeatures(logger_level="error")
        time, values = self.features.reference_feature(1, 1, 1)

        self.assertIsNone(time)
        self.assertIsNone(values)
Exemplo n.º 4
0
    def test_reference_feature(self):
        self.features = GeneralSpikingFeatures()
        time, values = self.features.reference_feature(1, 1, 1)

        self.assertIsNone(time)
        self.assertIsNone(values)
Exemplo n.º 5
0
    def test_calculate_spikes(self):
        self.features = GeneralSpikingFeatures()

        spikes = self.features.calculate_spikes(self.time, self.values)

        self.assertEqual(spikes.nr_spikes, 12)
Exemplo n.º 6
0
    def test_initNone(self):
        self.features = GeneralSpikingFeatures()

        self.assertIsInstance(self.features, GeneralSpikingFeatures)
        self.assertIsNone(self.features.spikes)
        self.assertIn("calculate_spikes", self.features.utility_methods)