Skip to content

DOC Add comment about input checking in pairwise_distances #31170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sklearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,7 @@ def _pairwise_callable(X, Y, metric, ensure_all_finite=True, **kwds):
Y,
dtype=None,
ensure_all_finite=ensure_all_finite,
# No input dimension checking done for custom metrics (left to user)
ensure_2d=False,
)

Expand Down Expand Up @@ -2411,6 +2412,10 @@ def pairwise_distances(
sklearn.metrics.pairwise.paired_distances : Computes the distances between
corresponding elements of two arrays.

Notes
-----
If metric is a callable, no restrictions are placed on `X` and `Y` dimensions.

Examples
--------
>>> from sklearn.metrics.pairwise import pairwise_distances
Expand Down Expand Up @@ -2637,7 +2642,7 @@ def pairwise_kernels(

Notes
-----
If metric is 'precomputed', Y is ignored and X is returned.
If metric is a callable, no restrictions are placed on `X` and `Y` dimensions.

Examples
--------
Expand Down