Enhance double_linear_search doctests with comprehensive examples#14285
Enhance double_linear_search doctests with comprehensive examples#14285JesunAhmadUshno wants to merge 2 commits intoTheAlgorithms:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR claims to enhance doctest coverage for double_linear_search() but actually contains multiple unrelated changes across different files. The main changes include:
Changes:
- Added 13 new doctest examples to
double_linear_search()(lines 26-63) - Migrated several files from
TypeVarto PEP 695 generic syntax - Updated type hints in
check_bipatrite.pyto be more generic - Minor code cleanup in
hash_table_with_linked_list.py
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| searches/double_linear_search.py | Enhanced docstring with 13 new doctests covering edge cases, duplicates, and negative numbers |
| searches/jump_search.py | Migrated from TypeVar to PEP 695 syntax (def jump_search[T: Comparable]) |
| machine_learning/linear_discriminant_analysis.py | Migrated valid_input function from TypeVar to PEP 695 syntax |
| graphs/check_bipatrite.py | Improved type hints to use Mapping[Hashable, Iterable[Hashable]] and removed FIXME comments |
| data_structures/hashing/hash_table_with_linked_list.py | Changed deque([]) to deque() for cleaner initialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from typing import Any, Protocol | ||
|
|
||
|
|
||
| class Comparable(Protocol): | ||
| def __lt__(self, other: Any, /) -> bool: ... | ||
|
|
||
|
|
||
| T = TypeVar("T", bound=Comparable) | ||
|
|
||
|
|
||
| def jump_search(arr: Sequence[T], item: T) -> int: | ||
| def jump_search[T: Comparable](arr: Sequence[T], item: T) -> int: |
There was a problem hiding this comment.
The PR description states "Enhanced doctest coverage for double_linear_search()" but this file contains unrelated changes migrating from TypeVar to PEP 695 generic syntax. This change (along with similar changes in machine_learning/linear_discriminant_analysis.py, graphs/check_bipatrite.py, and data_structures/hashing/hash_table_with_linked_list.py) should either be mentioned in the PR description or submitted as a separate PR focused on type annotation modernization.
Summary
Enhanced doctest coverage for
double_linear_search()with 17 comprehensive test examples covering:Changes
python -m doctest -v double_linear_search.pyChecklist