Add doctest to hashes/hamming_code.py (#10961)

This commit is contained in:
Tiela Rose Black-Law 2023-10-27 14:13:51 -07:00 committed by GitHub
parent 0eb1825af2
commit 5df16f11eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,6 +77,10 @@ def emitter_converter(size_par, data):
>>> emitter_converter(4, "101010111111")
['1', '1', '1', '1', '0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1']
>>> emitter_converter(5, "101010111111")
Traceback (most recent call last):
...
ValueError: size of parity don't match with size of data
"""
if size_par + len(data) <= 2**size_par - (len(data) - 1):
raise ValueError("size of parity don't match with size of data")