DOC Fix off-by-one indexing error in paired_manhattan_distances
Reference Issues/PRs
Fixes #34315
What does this implement/fix? Explain your changes.
This PR fixes an off-by-one indexing error in the docstring for paired_manhattan_distances within sklearn/metrics/pairwise.py.
The previous docstring stated that distances are calculated up to (X[n_samples], Y[n_samples]). Since Python uses 0-based indexing, attempting to access the n_samples index raises an IndexError in practice. This PR corrects the documentation to accurately reference the final elements as (X[n_samples - 1], Y[n_samples - 1]).
AI usage disclosure
I used AI assistance for:
- formatting this template
Any other comments?
I've ensured this is fully human-reviewed and conforms to the guidelines. Let me know if anything else is needed!
Thank you for opening your first pull request to scikit-learn! 🎉
To help get your contribution reviewed, please make sure that:
- You have filled out the pull request template.
- The pull request addresses an existing issue that is ready for contribution (e.g. not tagged as "Needs Triage", "Needs Decision", ...). If you are proposing a new feature, please open an issue to discuss it first.
- There are no other open pull requests already targeting the same issue.
- You have followed the pull request checklist. In particular, linting and tests should pass.
Hey @virchan! I saw you had to close PR #34349 earlier today because an automated bot tried to blindly fix my issue (#34315).
I was originally holding off on claiming it until the Needs Triage label was officially removed, but to prevent any more AI-spam tools from scraping it and wasting reviewers' time, I went ahead and pushed this manually.
Let me know if this looks good from your end
gentle ping to the maintainers,
the single failed cython-lint check is on an unrelated file (_dbscan_inner.pyx), please let me know if my docstring fix here is good to go or you need me to adjust anything here. Happy to make any changes!
@AnneBeyer hi, i have made the changes as you requested please let me know if that’d be all or if you want me to change anything. Thank you for looking into this :)
Thank you, @shipitdev! One small nit, otherwise LGTM!
Could you update the title to reflect the new scope as well? (This will become the commit message once this get's merged.)
oh yes! For sure. I'll update the title to something the covers the scope here
Thanks so much for the review, @AnneBeyer! Sorry for the delay in applying these, they didn't show up in my GitHub app initially. All fixed now. I really appreciate your time!
I apologize for the untidy history and multiple updates over the last few minutes. I was attempting to squash my commits but encountered some rebase issues, so I decided to leave the two commits intact rather than risk losing the changes. Thank you again for the review and your patience!"
@AnneBeyer gentle ping, i'm happy to make any changes. Please let me know if this looks good from your end.