test_prrt_coding_configuration.py 1.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import unittest
import math
# import os, sys
# import pyximport
# pyximport.install()
# sys.path.append(os.path.join(os.path.dirname(__file__), '/home/local/Documents/thesis/hecps/code/PRRT/prrt'))
import prrt

# print(sys.path)
# print(dir(prrt.__path__))
# print(prrt.__file__)
12
class TestPrrtCodingConfiguration(unittest.TestCase):
13 14

    def test_ri_01(self):
15 16 17 18 19
        prrt_cp_obj = prrt.PrrtChannelParameters(0.1, 0, 0, 0, 0, 0)
        prrt_cc_obj = prrt.PrrtCodingConfiguration(5, 2, [0, 1, 2])
        ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
        print("RI for test config: (n, k, n_p)=(5, 2, [0, 1, 2]) , p_e = 0.1 >> ", ri)
        assert math.isclose(ri, 0.01445, rel_tol=1e-03)
20 21

    def test_ri_02(self):
22 23 24 25 26
        prrt_cp_obj = prrt.PrrtChannelParameters(0.01, 0, 0, 0, 0, 0)
        prrt_cc_obj = prrt.PrrtCodingConfiguration(5, 2, [0, 1, 2])
        ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
        print("RI for test config: (n, k, n_p)=(5, 2, [0, 1, 2]), p_e = 0.01 >> ", ri)
        assert math.isclose(ri, 0.0001490496, rel_tol=1e-03)
27 28

    def test_ri_03(self):
29 30 31 32 33
        prrt_cp_obj = prrt.PrrtChannelParameters(0.1, 0, 0, 0, 0, 0)
        prrt_cc_obj = prrt.PrrtCodingConfiguration(8, 2, [1, 1, 2, 2])
        ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
        print("RI for test config: (n, k, n_p)=(8, 2, [1, 1, 2, 2]), p_e = 0.1 >> ", ri)
        assert math.isclose(ri, 0.50190719, rel_tol=1e-03)
34 35 36

if __name__ == '__main__':
    unittest.main()