本文整理汇总了Python中Channel.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.reset方法的具体用法?Python Channel.reset怎么用?Python Channel.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HammingCode
# 需要导入模块: import Channel [as 别名]
# 或者: from Channel import reset [as 别名]
# print corrupted_string
hamming = HammingCode()
# a = hamming.decode_chunks(hamming.encode_chunks(ascii_bitstring))
# print book
# print ascii_bitstring
# print chunk_bitstring("".join(ascii_bitstring), 8)
# for c in chunk_bitstring("".join(ascii_bitstring), 8):
# print c, convert_binary_to_ascii(c)
# print "".join([convert_binary_to_ascii(x) for x in chunk_bitstring("".join(ascii_bitstring), 7)])
# sys.exit(0)
# Now use the hamming coder to send it with error correction and ascii
print "Sending ascii bitstring over channel"
channel.reset()
hamming_ascii = hamming.encode_chunks(ascii_bitstring)
hamming_corrupted_bitstring = channel.binary_symmetric_channel(hamming_ascii, perror=0.02)
print "Decoding ascii bitstring"
hamming_decoded_ascii = hamming.decode_chunks(hamming_corrupted_bitstring)
# print "TOTAL ERRORS DETECTED: ", hamming.errors
hamming_ascii_final = "".join([convert_binary_to_ascii(x) for x in chunk_bitstring("".join(hamming_decoded_ascii), 8)])
# print hamming_ascii_final
print "A. NUM CHARS IN DOC: ", len("".join(book))
print "B. BINARY CHARS IN DOC: ", len(ascii_bitstring)
print "C. NUM ERRORS FROM CHANNEL: ", channel.num_errors
print "D. NUM NO ERRORS FROM CHANNEL: ", channel.no_errors
print "E. NUM CODEWORDS 1 ERR: ", channel.one_errors
print "F. NUM CODEWORDS 2 ERR: ", channel.double_errors
print "G. MORE THAN 2 ERRORS: ", channel.more_than_double_errors