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

Conversation

tielarose
Copy link
Contributor

Describe your change:

Added a doctest to hashes/hamming_code.py to increase test coverage to 100%

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 25, 2023
@tielarose tielarose changed the title "Contributes to #9943" Contributes to #9943 Oct 25, 2023
@tielarose tielarose marked this pull request as draft October 25, 2023 20:17
@tielarose tielarose marked this pull request as ready for review October 25, 2023 20:18
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 25, 2023
@tielarose
Copy link
Contributor Author

I see that the build is failing with this error:

=========================== short test summary info ============================
FAILED web_programming/fetch_anime_and_play.py::web_programming.fetch_anime_and_play.get_anime_episode
============ 1 failed, 1725 passed, 1 warning in 114.91s (0:01:54) =============
Error: Process completed with exit code 1.

But I hadn't touched that file at all. Should I be trying to figure out what's wrong in that file? Even if I could figure it out, wouldn't that mean my pull request would touch more than one algorithm, which we're not supposed to do?

@@ -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 :)

@imSanko
Copy link
Contributor

imSanko commented Oct 26, 2023

I see that the build is failing with this error:

=========================== short test summary info ============================ FAILED web_programming/fetch_anime_and_play.py::web_programming.fetch_anime_and_play.get_anime_episode ============ 1 failed, 1725 passed, 1 warning in 114.91s (0:01:54) ============= Error: Process completed with exit code 1.

But I hadn't touched that file at all. Should I be trying to figure out what's wrong in that file? Even if I could figure it out, wouldn't that mean my pull request would touch more than one algorithm, which we're not supposed to do?

We need to check with it


2 items had failures:
1 of 1 in hamming_code.emitter_converter
1 of 1 in hamming_code.receptor_converter
4 tests in 5 items.
2 passed and 2 failed.
Test Failed 2 failures.

@cclauss
Copy link
Member

cclauss commented Oct 27, 2023

Looking at the failed build tests, it was some other file that failed. This one looks like it correctly tested the exceptions.

If the rerun of the tests pass then let's merge this one.

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 27, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 27, 2023
@cclauss cclauss changed the title Contributes to #9943 Add a doctest to hashes/hamming_code.py Oct 27, 2023
@cclauss cclauss merged commit 5df16f1 into TheAlgorithms:master Oct 27, 2023
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants