MAINT replace deprecated scipy distance_matrix with cdist#1188
Open
chaoz23 wants to merge 1 commit into
Open
Conversation
chaoz23
force-pushed
the
fix/smoten-scipy-cdist
branch
from
July 18, 2026 07:15
7aaa600 to
2d21704
Compare
scipy 1.18 deprecates scipy.spatial.distance_matrix in favor of scipy.spatial.distance.cdist (removal scheduled for scipy 1.20), which currently raises a DeprecationWarning (and fails the SMOTEN tests that treat warnings as errors). Switch ValueDifferenceMetric to cdist with the Minkowski metric; the computed distances are identical.
chaoz23
force-pushed
the
fix/smoten-scipy-cdist
branch
from
July 18, 2026 07:24
2d21704 to
d7d5503
Compare
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.
What
SciPy 1.18 deprecates
scipy.spatial.distance_matrixin favour ofscipy.spatial.distance.cdist(scheduled for removal in SciPy 1.20).ValueDifferenceMetric.pairwisestill calls it, so under SciPy ≥ 1.18 it emits aDeprecationWarning— which currently fails the SMOTEN test suite (warnings are treated as errors).Change
Switch the call to
cdist(..., metric="minkowski", p=self.k), which computes the identical Minkowski-p distance matrix.Verification
distance_matrixvscdist(metric="minkowski")match exactly (max abs diff0.0) forp = 1, 2, 3.imblearn/metrics/tests/test_pairwise.py— 132 passed (VDM results unchanged).imblearn/over_sampling/_smote/tests/test_smoten.py— 5 passed (previously failing on the deprecation).ruffandblackclean.No behavioural change; distances are identical.