Skip to content

Fix bugs and typo errors in closest_pair_of_points.py#14363

Open
Roy027 wants to merge 2 commits intoTheAlgorithms:masterfrom
Roy027:master
Open

Fix bugs and typo errors in closest_pair_of_points.py#14363
Roy027 wants to merge 2 commits intoTheAlgorithms:masterfrom
Roy027:master

Conversation

@Roy027
Copy link

@Roy027 Roy027 commented Mar 10, 2026

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

Description:
This PR refactors the closest_pair_of_points.py algorithm to improve reliability, type safety, and readability.

Key Changes:

  • Bug Fix: Corrected the comparison logic in dis_between_closest_in_strip to ensure all relevant points in the strip
    are checked correctly.
  • Type Hints: Added comprehensive Python type annotations (list[Any], tuple[Any, ...], int, float) to all function
    signatures for better IDE support and type safety.
  • Formatting: Refactored the code to comply with ruff standards, specifically wrapping long lines (E501) and ensuring
    consistent spacing.
  • Doctest Updates: Updated existing doctests to match the function outputs and added new test cases to verify the
    fixes.
  • Typo Fixes: Corrected minor spelling errors in the module's docstring and comments.

Checklist:

  • x] I have read [CONTRIBUTING.md (https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • x] All function parameters and return values are annotated with Python [type hints
    (https://docs.python.org/3/library/typing.html).
  • x] All functions have [doctests
    (https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) that pass the
    automated testing.
  • x] All new algorithms include at least one URL that points to Wikipedia or another similar explanation. (Algorithm
    explanation: [Wikipedia - Closest pair of points problem
    (https://en.wikipedia.org/wiki/Closest_pair_of_points_problem))
  • ] If this pull request resolves one or more open issues then the description above includes the issue number(s)
    with a [closing keyword
    (https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue): "Fixes
    #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Mar 10, 2026
@Roy027 Roy027 force-pushed the master branch 2 times, most recently from 06f4c84 to 46538b6 Compare March 10, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant