Beispiel #1
0
                point[1] = 1
                # линия вправо
                draw_s.line([(point[0], point[1]), (point[0] + 4, point[1])],
                            fill="black",
                            width=1)
                point[0] += 4
    im.save('digital_signal.png')
    # im.show()


# print("Введите числовую полседовательность")
# N = list(map(int, input().split()))
# print("Выберите способ кодирования", "NRZ", "NRZI", "MANCH", sep='\n')
if __name__ == '__main__':
    tk = ['NRZ', 'NRZI', 'MANCH']
    N = [i for i in range(255)]
    for tmp in tk:
        if tmp == "NRZ":
            nrz(N)
            print("Complete")
        elif tmp == "NRZI":
            nrzi(N)
            print("Complete")
        elif tmp == "MANCH":
            manch(N)
            print("Complete")
        else:
            print("Erorr")
        ng = Image.open('digital_signal.png')
        print(tmp, N == decode_img(ng, tmp))
 def test_nrz_0123(self):
     test_list = list(range(256))
     nrz(test_list)
     self.assertEqual(list(test_list), decode_img(Image.open('digital_signal.png'), 'NRZ'))
 def test_manch_random(self):
     test_list = [randint(0, 255) for x in range(1024)]
     manch(test_list)
     self.assertEqual(list(test_list), decode_img(Image.open('digital_signal.png'), 'MANCH'))
 def test_nrzi_random(self):
     test_list = [randint(0, 255) for x in range(1024)]
     nrzi(test_list)
     self.assertEqual(list(test_list), decode_img(Image.open('digital_signal.png'), 'NRZI'))
 def test_manch_longer(self):
     test_list = list(range(256))*3
     manch(test_list)
     self.assertEqual(list(test_list), decode_img(Image.open('digital_signal.png'), 'MANCH'))
 def test_nrzi_longer(self):
     test_list = list(range(256))*3
     nrzi(test_list)
     self.assertEqual(list(test_list), decode_img(Image.open('digital_signal.png'), 'NRZI'))