-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Merge insertion sort doesn't work #5774
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
Comments
In general I suggest you test all your sort algorithms on all permutations of |
This sounds like a great idea. There are test that all Euler solutions have to pass and you could create something similar for the sort algorithms. |
Hello, I'd like to take up this Issue with a fellow student of mine. (@yellowsto) We are both new to Open Source, but happy to learn! (so far we've read your contribution guidelines and some short tutorials how to work with github) Could we get this Issue assigned? |
@AilisOsswald Issues aren't really assigned here, anybody can work on them. You just have to open a PR with the changes that you plan to make. The maintainers will review it and merge it if it looks good :) |
Fixes TheAlgorithms#5774 merge_insertion_sort Co-Authored-By: AilisOsswald <[email protected]>
Fixes TheAlgorithms#5774 merge_insertion_sort Co-Authored-By: AilisOsswald <[email protected]>
Hey, we have wrote script which should make testing sort algorithms easier. Does this seem like a good idea? If yes, we could make a PR, but we wanted to check first. If someone wants to try:
We'd be happy about Feedback! |
Why do you not want to put a text file in your pull request? |
We thought one PR for one thing - and the PR we have know is for fixing the merge_insertion sort. |
I wonder why we are creating a txt file containing the permutations instead of doing #5774 (comment) |
Because we did not get to figure out how to put a for loop into the doctests - Since the syntac in a doctest works like
Now if i create all permutations anwant to run them what comes to my mind is: for i in range(len(permutations)): I wouldn't know how to convert this into a fitting docstring test, since my for still needs to run and all wouldn_t it be somewhat like this?
But this does not seem to work for us - that's why we did the file |
for clarification also, the txt file we have attached here is actually an .py file - but github does not support py files in comments |
Why does this have to be in doctests? |
@AilisOsswald Why not create a one-line list comprehension and check if all results are what we want? |
@remram44 I thought doctests were the standard for testing here Ohh, a one line seems like a good idea! so far I have tried: But this gives back a 120 long list of None's - which isn't really what i looked for BTW Thanks for all the Feedback, everyone! |
I was thinking:
|
>>> all(merge_insertion_sort(x) == [0, 1, 2, 3, 4] for x in permutations)
True |
Certainly should work, but we wouldn't see for which permutation it wouldn't work? |
(Latest edit) |
Yes!
should work perfectly, I think we don't even need the print, because if it works, the list is empty and we should get no feedback. but if it doesn't work we will get the "expected [] but got [(where_it_did_not_work)]" and will see the permutations that failed anyways |
>>> all(a == e for a, e in zip(actual, expected))
True |
Fixes TheAlgorithms#5774 added permutation range from 0 to 4 Co-Authored-By: AilisOsswald <[email protected]>
* Update merge_insertion_sort.py Fixes #5774 merge_insertion_sort Co-Authored-By: AilisOsswald <[email protected]> * Update merge_insertion_sort.py Fixes #5774 merge_insertion_sort Co-Authored-By: AilisOsswald <[email protected]> * Update merge_insertion_sort.py Fixes #5774 added permutation range from 0 to 4 Co-Authored-By: AilisOsswald <[email protected]> * Use `all()` Co-authored-by: AilisOsswald <[email protected]> Co-authored-by: John Law <[email protected]>
Cc @ulwlu #2211
sorts/merge_insertion_sort.py
The text was updated successfully, but these errors were encountered: