Beispiel #1
0
    def add_history_test(self):

        sig = SignalManager(generator=sine_wave())

        sig.remove_channels(['sine'])

        self.assertEqual(["remove_channels(['sine'], )"], sig.history)
Beispiel #2
0
	def fourier_transform_test(self):
		freq = 50
		phase = np.pi/2

		sig = SignalManager(generator=sine_wave(freq=freq, phase=phase))

		sig.fourier_transform()

		max_freq_idx = np.where(sig.spectrum == np.max(sig.spectrum))[2][0]

		self.assertAlmostEqual(freq, sig.spectrum_freqs[max_freq_idx])
		self.assertAlmostEqual(phase, sig.phase[:, :, max_freq_idx][0][0])
Beispiel #3
0
    def chaining_test():
        data = {
            'fs': 512,
            'num_channels': 1,
            'channel_names': ['sine1'],
            'epochs': 1
        }

        sig = SignalManager(generator=sine_wave(data=data))

        sig.extract_time_range(0, 2)\
            .extract_time_range(0, 1)
Beispiel #4
0
    def extract_time_range_test(self):
        data = {
            'fs': 512,
            'num_channels': 1,
            'channel_names': ['sine1'],
            'epochs': 1
        }

        sig = SignalManager(generator=sine_wave(data=data))

        sig.extract_time_range(0, 1)

        self.assertEqual(sig.data.shape, (1, 1, 512))
Beispiel #5
0
    def extract_channel_test(self):
        data = {
            'fs': 512,
            'num_channels': 3,
            'channel_names': ['sine1', 'sine2', 'sine3'],
            'epochs': 1
        }

        sig = SignalManager(generator=sine_wave(data=data))

        sig.extract_channels(['sine2', 'sine3'])

        self.assertEqual(sig.num_channels, 2)
        self.assertEqual(sig.channel_names, ['sine2', 'sine3'])
        self.assertEqual(sig.data.shape, (1, 2, 10240))
Beispiel #6
0
    def register_plugin_test(self):
        class TestPlugin(PluginManager):
            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                self.custom = []

            def custom_function(self):
                return self.custom

        SignalManager.register_plugin(TestPlugin)

        self.assertTrue(
            TestPlugin in SignalManager.__bases__,
            'TestPlugin should be a subclass of the PluginManager')

        sig = SignalManager()
        self.assertEqual([], sig.custom_function())
Beispiel #7
0
    def duplicate_register_plugin_test(self):
        class TestPlugin(PluginManager):
            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                self.custom = []

            def custom_function(self):
                return self.custom

        length_before = len(SignalManager.__bases__)
        SignalManager.register_plugin(TestPlugin)
        SignalManager.register_plugin(TestPlugin)
        length_after = len(SignalManager.__bases__)

        self.assertTrue(length_after - length_before == 1,
                        'Should not create duplicate plugins')

        sig = SignalManager()
        self.assertEqual([], sig.custom_function())
Beispiel #8
0
    def graphics_time_plot_test(self):
        freq = 10
        phase = np.pi / 2

        data = {
            'fs': 512,
            'num_channels': 2,
            'channel_names': ['sine1', 'sine2'],
            'epochs': 2
        }

        sig = SignalManager(
            generator=sine_wave(freq=freq, phase=phase, data=data))

        sig.graphics_time_plot()

        fig, ax = plt.subplots(nrows=sig.num_channels,
                               ncols=1,
                               figsize=(10, 10))

        sig.graphics_time_plot(fig, ax)

        plt.show()
Beispiel #9
0
 def smoke_test():
     SignalManager()
Beispiel #10
0
 def smoke_test():
     SignalManager(sine_wave())