-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
TST Fix scipy DeprecationWarning from wminkowski in nightly #18930
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
Conversation
I think we can rely on scipy one for simplicity. Maybe we could upgrade the test to also check I am running scipy 1.5 and this |
The second part of my comment was not addressed:
Can you give it a try? The oldest version of scipy we support (0.19.1 as defined in |
I'm sorry @ogrisel, I was having a blind spot on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We can ignore the coverage failure because all the cases cannot be tested prior to the scipy 1.6 release but the code looks correct. And even if it is not, the nightly builds will catch it quickly after the merge of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @cmarmo !
except ImportError: | ||
# In scipy 1.6.0, wminkowski is deprecated and minkowski | ||
# should be used instead. | ||
from scipy.spatial.distance import minkowski as wminkowski |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for coverage, the ImportError
will not trigger until scipy 1.8 is released and wminkowski
is removed.
(This is a comment: no changes required here)
if sp_version >= parse_version("1.6.0") and ( | ||
metric == wminkowski or metric == 'wminkowski' | ||
): | ||
metric = 'minkowski' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we can skip because minkowski
is tested explicitly and this would be testing it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand correctly: I have then skipped the wminkowski and 'wminkowski' test for scipy >=1.6.0, Is that what you meant? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have then skipped the wminkowski and 'wminkowski' test for scipy >=1.6.0, Is that what you meant?
Yes this is what I meant.
I think we can skip here because this PR adds metric = 'minkowski'
to pytest.mark.parameterize
, so metric = 'minkowski'
will get tested when it gets to that test case.
@@ -245,13 +254,26 @@ def callable_rbf_kernel(x, y, **kwds): | |||
@pytest.mark.parametrize( | |||
'func, metric, kwds', | |||
[(pairwise_distances, 'euclidean', {}), | |||
(pairwise_distances, minkowski, _minkowski_kwds), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can include the skip here:
(pairwise_distances, minkowski, _minkowski_kwds), | |
pytest.param(pairwise_distances, minkowski, _minkowski_kwds, | |
marks=pytest.mark.skipif(sp_version < parse_version("1.0")), | |
reason="minkoski does not accept ..."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this kind of parametrization should be applied to the 'minkowsi' case too, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently, the nightly build is not able to run without #19062 merged |
What does this implement/fix? Explain your changes.
This pull request modifies tests to use 'minkoski' metrics when 'wminkowski' is called when scipy version is >= 1.6.
This remove some DeprecationWarnings in the nightly build.
Any other comments?
scikit-learn/sklearn/metrics/tests/test_pairwise.py
Line 236 in eaa45c8
sklearn/metrics/pairwise.py
) or we can rely on the scipy one? Thanks!