Put simulation code into separate module

This commit is contained in:
2022-11-25 19:34:19 +01:00
parent ec03f9f5f1
commit b33a0735f0
6 changed files with 252 additions and 263 deletions

View File

@@ -1,25 +1,7 @@
import unittest
import numpy as np
from utility import simulation, noise, codes
class CountBitErrorsTestCase(unittest.TestCase):
"""Test case for bit error counting."""
def test_count_bit_errors(self):
d1 = np.array([0, 0, 0, 0])
y_hat1 = np.array([0, 1, 0, 1])
d2 = np.array([0, 0, 0, 0])
y_hat2 = np.array([0, 0, 0, 0])
d3 = np.array([0, 0, 0, 0])
y_hat3 = np.array([1, 1, 1, 1])
self.assertEqual(simulation.count_bit_errors(d1, y_hat1), 2)
self.assertEqual(simulation.count_bit_errors(d2, y_hat2), 0)
self.assertEqual(simulation.count_bit_errors(d3, y_hat3), 4)
from utility import noise, codes
# TODO: Rewrite tests for new SNR calculation