sorts: make pancake_sort generic over Comparable items - #15311
Open
Rokesh2008 wants to merge 2 commits into
Open
sorts: make pancake_sort generic over Comparable items#15311Rokesh2008 wants to merge 2 commits into
Rokesh2008 wants to merge 2 commits into
Conversation
Part of TheAlgorithms#15234 - switch pancake_sort's TypeVar to the Comparable/TypeVar-bound pattern used by insertion_sort.py - add doctests covering strings, floats, and random data - register pancake_sort in tests/test_sorts.py's shared battery and the non-comparable-items rejection test
Member
|
ON HOLD: Our focus is on merging or closing old pull requests before October 1st. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #15234
This contribution:
pancake_sort's type hint from a bareTypeVarto theComparable/TypeVar-bound pattern used byinsertion_sort.py(the reference implementation for this issue)pancake_sortintests/test_sorts.py's sharedSORTSbattery (checked againstsorted()on the existing case set, including dataclass/NamedTuple items) and intest_sort_rejects_non_comparable_items(confirmsTypeErroron mixed int/str input)Tests:
python -m doctest -v sorts/pancake_sort.py— 10/10 passedpancake_sortagainst every case intests/test_sorts.py'sCASEStuple and confirmed it matchessorted(), includingPerson/Dogcomparable objectspancake_sort([1, "a"])raisesTypeErrorNote: linking with
Part of #15234rather thanFixes/Closes, per the issue's contribution guidance, since other checkboxes on that tracking issue remain open.