8000 Centralized tests for sorting algorithms by slarse · Pull Request #723 · TheAlgorithms/Python · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@slarse
Copy link
@slarse slarse commented Feb 27, 2019

@poyea We bit off a bit more than we could chew, but we managed to finish parts of the unified test suite. I will try to bring it in bite-sized chunks, starting with this, if there is interest from your part. Our whole set of changes was a whopping 3800+/1400- lines.

This PR builds on #714, and the comments there are still applicable here. Additionally, this PR adds:

Tests

  • The import tests (just testing to import every module) have been removed to focus on the sorting part only (939c299)
  • Generic tests for out-of-place sorting algorithms (7edc521)
    • These tests are parameterized by function name. Any sorting function that just takes a collection can be added to the test suite bu adding it to the SORTS list.
  • Generic tests for in-place sorting algorithms (e4f9103)
    • Same case as above, in-place sorting algorithms can be tested by adding them to the SORTS list.
  • Tests for bogosort (e5c68a8)
    • Since bogosort is non-deterministic, running it on large lists is... inadvisable.

Bugfixes

  • Fix for bucket_sort crash on empty input (bd61f06)
  • Fix for timsort crash empty input (a9f9069)
  • FIx for merge_sort_fastest destroying the input list (2e382d0)
    • On a side note, this merge sort is O(n^2), not O(n) as it claims, because of the removals from the original list.
  • Fix for a rare edge case in comb_sort (1b7a82d)
  • Fix for tree_sort discarding duplicate elements (b46d67a)
  • Some minor fixes in files to make them importable from the root of the project

Broken algorithms

  • timsort
    • There are some edge-cases where timsort fails to sort properly, We don't know why.
  • radix_sort
    • Fails most tests, it appears that it cannot handle negative numbers (at the very least, may be more problems).

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0