Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a doctest to hashes/hamming_code.py #10961

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hashes/hamming_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor

@imSanko imSanko Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried running python3 -m doctest -v hashes/hamming_code.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, when I run it it shows this:

1 items had no tests:
hamming_code
4 items passed all tests:
1 tests in hamming_code.emitter_converter
1 tests in hamming_code.receptor_converter
1 tests in hamming_code.text_from_bits
1 tests in hamming_code.text_to_bits
4 tests in 5 items.
4 passed and 0 failed.
Test passed.

But I see below that when you ran it there were tests failing in this file. Any guidance on what I might be doing wrong that tests are passing for me, but not when someone else is running it? Thank you for your help! This is my first attempt at an open source contribution so I truly appreciate your help navigating all of this :)

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")
Expand Down