-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Replace double_ended_queue.py #5429
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
We can replace this file https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/double_ended_queue.py with your implementation, but use |
@poyea I do! I added the comparison on each doctest. Tell me if it's ok. |
Fixed issues with pre-commit. Hopefully that works. |
values_list.append(aux.val) | ||
aux = aux.next | ||
|
||
return "[" + ", ".join(repr(val) for val in values_list) + "]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.python.org/3/library/doctest.html
if __name__ == "__main__":
import doctest
doctest.testmod()
@grbenjamin Please simply use this file to replace the existing
|
I guess we can do: list(built_in_deque) == list(our_deque) ? |
Please provide an example of use of |
In def is_empty(self) -> bool:
"""
>>> ...
>>> list(built_in_deque) == list(our_deque)
"""
... ? Or in all other doctests? @poyea |
@grbenjamin Yes, something like this, wherever we want to test the implementation : https://docs.python.org/3/library/collections.html?highlight=deque#collections.deque |
>>> from collections import deque
>>> d_collections = deque('123456') etc. |
Done, replaced the existing file and added more tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you for your pull request!🤩
* Add deque_from_scratch.py * added deque_from_scratch.py * add extend, extendleft and make comparison * updated operations list * fix doctest on Deque.__iter__ * pre-commit fix * time complexity comments, change type hints * pre-commit fix * added more doctests
Replaced double_ended_queue.py with an implementation of it with nodes.
Checklist:
Fixes: #{$ISSUE_NO}
.