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

Docstrings and formatting improvements #2418

Merged
merged 5 commits into from Sep 14, 2020

Conversation

@Hasenn
Copy link
Contributor

Hasenn commented Sep 12, 2020

Describe your change:

I've been correcting some spelling in docstrings and applying PEP8 autoformatting to scripts i read. I didn't make a single PR per script as the review should be pretty straightforward from reading the diffs, and i didn't change much per file.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • 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 have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
@spamegg1
Copy link
Contributor

spamegg1 commented Sep 12, 2020

Build log says:

_______________________ [doctest] rat_in_maze.solve_maze _______________________
040 >>> solve_maze(maze)
041 [1, 1, 1]
042 [0, 0, 1]
043 [0, 0, 1]
044 True
045
046 >>> maze = [[0, 1, 0],
047 ... [0, 1, 0],
048 ... [1, 0, 0]]
049 >>> solve_maze(maze)
Expected:
Solution does not exist!
False
Got:
Solution does not exists!
False
/home/travis/build/TheAlgorithms/Python/backtracking/rat_in_maze.py:49: DocTestFailure

@Hasenn
Copy link
Contributor Author

Hasenn commented Sep 12, 2020

oh, yeah it was a doctest i need to find the print statement too and update it

@poyea
poyea approved these changes Sep 13, 2020
Copy link
Member

poyea left a comment

Thank you for your pull request!🤩

@@ -131,7 +131,8 @@ def prime_implicant_chart(prime_implicants, binary):
>>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5'])
[[1]]
"""
chart = [[0 for x in range(len(binary))] for x in range(len(prime_implicants))]
chart = [[0 for x in range(len(binary))]

This comment has been minimized.

@cclauss

cclauss Sep 13, 2020

Member

My sense is that psf/black will undo this change.

# Define a new cell and add it to the new generation
situation = 7 - int(f"{left_neighbor}{cells[time][i]}{right_neighbor}", 2)
situation = 7 - int(

This comment has been minimized.

@cclauss

cclauss Sep 13, 2020

Member

My sense is that psf/black will undo this change.

False
>>> maze = [[0, 1],
... [1, 0]]
>>> solve_maze(maze)
Solution does not exists!
Solution does not exist!

This comment has been minimized.

@cclauss

cclauss Sep 13, 2020

Member
Suggested change
Solution does not exist!
No solution exists!
@@ -63,16 +63,16 @@ def solve_maze(maze: list) -> bool:
if solved:
print("\n".join(str(row) for row in solutions))
else:
print("Solution does not exists!")
print("Solution does not exist!")

This comment has been minimized.

@cclauss

cclauss Sep 13, 2020

Member
Suggested change
print("Solution does not exist!")
print("No solution exists!")

This comment has been minimized.

@cclauss

cclauss Sep 13, 2020

Member

I would raise an exception but that is a personal choice.

@Hasenn
Copy link
Contributor Author

Hasenn commented Sep 13, 2020

thanks @cclauss i applied black and changed the text to "No solution exists". I don't want to raise an exception to avoid having long error messages in the doctests (they are already 55 lines long)

    This method is recursive starting from (i, j) and going in one of four directions:
    up, down, left, right.
    If a path is found to destination it returns True otherwise it returns False.
@cclauss cclauss merged commit 10aa214 into TheAlgorithms:master Sep 14, 2020
2 checks passed
2 checks passed
codespell
Details
Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.