当前位置: 首页>>代码示例>>Python>>正文


Python Channel.reset方法代码示例

本文整理汇总了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
开发者ID:smidget,项目名称:InfoTheoryAssignment6,代码行数:33,代码来源:Main.py


注:本文中的Channel.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。