Add type hints and tests. - #2461
Conversation
Sort collection and remove the assertion logic. Co-authored-by: Christian Clauss <cclauss@me.com>
There was a problem hiding this comment.
Does this provide the right answer if the user inputs an out-of-order list?
There was a problem hiding this comment.
It does not, I think it is better to return to the assert_sorted logic.
There was a problem hiding this comment.
OK but let's do it inline. We don't need a separate function.
There was a problem hiding this comment.
I guess my error could be avoided by testing that part of the code, however the use of inputs make it hard to test. Do you know any way that the main could be tested ?
There was a problem hiding this comment.
Sure.
def perform_searches(collection: List[int], target: int) -> None:
# put lines 159, 160, and 162-168 under this function and
# then you can test `perform_searches()` all day long.There was a problem hiding this comment.
Ok, I guess thats the same than testing each one of the two searches functions.
I meant something to try to test different user inputs via the input function, not when the collection is already defined.
|
Please resolve conflicts. |
|
Good to go ! @cclauss sorry for the delay. |
|
Hey, if possible can you update the variable names to |
dhruvmanila
left a comment
There was a problem hiding this comment.
Yes! Thank you for your contribution! :)
* Add type hints, documentation and tests.
* Update searches/ternary_search.py
Sort collection and remove the assertion logic.
Co-authored-by: Christian Clauss <cclauss@me.com>
* Remove assert sorted logic.
* Add assertion list is ordered.
* updating DIRECTORY.md
* updating DIRECTORY.md
* Format with black.
* Change names of variables to descriptive names
* Remove print in doctests
* Fix variables to snake_case notation.
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add type hints, documentation and tests.
* Update searches/ternary_search.py
Sort collection and remove the assertion logic.
Co-authored-by: Christian Clauss <cclauss@me.com>
* Remove assert sorted logic.
* Add assertion list is ordered.
* updating DIRECTORY.md
* updating DIRECTORY.md
* Format with black.
* Change names of variables to descriptive names
* Remove print in doctests
* Fix variables to snake_case notation.
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add type hints, documentation and tests.
* Update searches/ternary_search.py
Sort collection and remove the assertion logic.
Co-authored-by: Christian Clauss <cclauss@me.com>
* Remove assert sorted logic.
* Add assertion list is ordered.
* updating DIRECTORY.md
* updating DIRECTORY.md
* Format with black.
* Change names of variables to descriptive names
* Remove print in doctests
* Fix variables to snake_case notation.
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add type hints, documentation and tests.
* Update searches/ternary_search.py
Sort collection and remove the assertion logic.
Co-authored-by: Christian Clauss <cclauss@me.com>
* Remove assert sorted logic.
* Add assertion list is ordered.
* updating DIRECTORY.md
* updating DIRECTORY.md
* Format with black.
* Change names of variables to descriptive names
* Remove print in doctests
* Fix variables to snake_case notation.
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>

Continuing in line with #2128.
Add type hints and doctests corrected some little changes things that are not Python idiomatic.
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.