Repository navigation
MNT Deprecate paired_*_distances and paired_distances public functions - #33809
Open
Pedrom2002 wants to merge 3 commits into
Open
Pedrom2002 wants to merge 3 commits into
Pedrom2002 wants to merge 3 commits into
Conversation
Deprecates `paired_distances`, `paired_euclidean_distances`, `paired_manhattan_distances` and `paired_cosine_distances` in 1.10; removal scheduled for 1.12. Internal callers now use module-private `_paired_*` helpers to avoid triggering the deprecation warnings on their own use. The `PAIRED_DISTANCES` dict is kept (same name) and repointed to the private implementations. Continues the stalled work in scikit-learn#30537 (originally based on scikit-learn#27129). Co-authored-by: Success Moses <[email protected]> Co-authored-by: Shreesha Kumar Bhat <[email protected]>
These public functions are deprecated in 1.10 and will be removed in 1.12; promoting their array-api support would mislead users. Keep the :func:\`paired_*_distances\` entries in \`doc/api_reference.py\` so the deprecated pages stay reachable during the removal cycle. Co-authored-by: Success Moses <[email protected]> Co-authored-by: Shreesha Kumar Bhat <[email protected]>
The CI runs doctests with SKLEARN_WARNINGS_AS_ERRORS=1, which elevates the FutureWarning emitted by the @deprecated decorator to an exception and breaks the doctests for the four paired_*_distances examples. Keep the examples visible in the rendered docs but skip their execution with # doctest: +SKIP until the functions are removed. Co-authored-by: Success Moses <[email protected]> Co-authored-by: Shreesha Kumar Bhat <[email protected]>
|
Hi @Pedrom2002 |
This branch has not been deployed
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.
Reference Issues/PRs
Continues the stalled #30537 (which in turn continued #27129). Fixes #26982.
The original author (@SuccessMoses) was last active on the branch in December 2024 and did not respond to the maintainer re-ping in July 2025. Work has been picked up with full credit preserved (see commit trailers and changelog).
What does this implement/fix?
Deprecates the four public
metrics.pairwisefunctionspaired_distances,paired_euclidean_distances,paired_manhattan_distancesandpaired_cosine_distancesvia the@deprecateddecorator. Deprecation targets 1.10; removal scheduledfor 1.12.
Internal callers (only
sklearn.cluster._agglomerative.linkage_tree)now go through module-private
_paired_*helpers so they do nottrigger the deprecation warnings on their own use. The
PAIRED_DISTANCESdict is kept under the same name (per reviewfeedback in #30537) but its values are repointed to the private
implementations.
Changes relative to #30537
Addresses all outstanding review comments from @StefanieSenger:
1.10, remove in 1.12 (was 1.7/1.9 and then 1.8/1.10).
deprecated functions (the prior iteration had changed them to
reference the private
_paired_*counterparts, which we do not wantto expose in API docs).
PAIRED_DISTANCES(no rename to_PAIRED_DISTANCES)so no other import sites need to change.
@ignore_warnings(category=FutureWarning)as a decorator forthe new parametrized
test_deprecated_function_param_validation,per the suggestion to use the context manager / decorator form.
Test plan
pytest sklearn/metrics/tests/test_pairwise.py -k pairedpytest sklearn/tests/test_public_functions.py -k pairedpytest sklearn/cluster/tests/test_hierarchical.py(sanitycheck for internal
_paired_distancescall site)pytest sklearn/metrics/tests/test_common.py -k array_apiNotes:
test_paired_distances_deprecationasserts theFutureWarningis raised for each of the four deprecated publicfunctions.
test_deprecated_function_param_validationkeeps param-validationcoverage while silencing the expected
FutureWarning.