Skip to content

Fixing and adding notes to the recursive method#5903

Closed
one-third-reason wants to merge 2 commits intoTheAlgorithms:masterfrom
one-third-reason:patch-1
Closed

Fixing and adding notes to the recursive method#5903
one-third-reason wants to merge 2 commits intoTheAlgorithms:masterfrom
one-third-reason:patch-1

Conversation

@one-third-reason
Copy link

In the examples of the recursive method output, the function was written as "fib_iterative()" instead of "fib_recursive()"
The recursion depth limit thing is added too as a note, and a way to increase the limit is also added

Also I'm not a native english speaker so there might be some wrong gramars but I hope there are none

Describe your change:

  • 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}.

In the examples of the recursive method output, the function was written as "fib_iterative()" instead of "fib_recursive()"
The recursion depth limit thing is added too as a note, and a way to increase the limit is also added

Also I'm not a native english speaker so there might be some wrong gramar or something else
@ghost ghost added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Jan 4, 2022
Comment on lines 84 to 90
NOTE: The current recursion depth limit is 1000 (thus n > 1000 won't work) and it will throw an error if it's exceeded to prevent infinite recursion / stack overflow.
The limit can be changed with the sys module, but setting it too high might evoke a crash:

import sys
sys.setrecursionlimit(limit)

A better solution is to rewrite the code without recursion e.g. with loops, like the iterative method.

Choose a reason for hiding this comment

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

Two points:

  1. may not be a good idea to exceed 100 symbols/line.
  2. won't this chunk raise a sphinx warning if we try generating docs?

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry but may you explain what a sphinx warning is? Thank you

Choose a reason for hiding this comment

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

Documentation generator (link).

OK, we can skip the 2nd point, just ensure each line is not longer than 100 symbols

Copy link
Author

Choose a reason for hiding this comment

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

Ah ok I'll try shorten those texts

Choose a reason for hiding this comment

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

Or try moving text to the next line

Copy link
Author

@one-third-reason one-third-reason Jan 15, 2022

Choose a reason for hiding this comment

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

Or try moving text to the next line

Good idea 😅

Alright I've changed it, I hope it's fine now

Choose a reason for hiding this comment

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

Now, it does not exceed. I hope docs are only for developers to see, so now it's pretty fine regarding length

Copy link

@andrei-polukhin andrei-polukhin left a comment

Choose a reason for hiding this comment

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

Looks pretty fine, at least for a stranger like me :)

@andrei-polukhin
Copy link

Need to get a review of someone more knowledgeable, like @Kush1101

@ghost ghost added the tests are failing Do not merge until tests pass label Jan 30, 2022
@stale
Copy link

stale bot commented Apr 18, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Apr 18, 2022
@cclauss
Copy link
Member

cclauss commented Oct 1, 2022

In preparation for that denial-of-service attack that is Hacktoberfest, I am closing all pull requests that do not have passing tests.

@cclauss cclauss closed this Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files stale Used to mark an issue or pull request stale. tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants