Repository navigation
TST Fix scipy DeprecationWarning from wminkowski in nightly - #18930
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 |
|
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. |
thomasjpfan
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
| @pytest.mark.parametrize( | ||
| 'func, metric, kwds', | ||
| [(pairwise_distances, 'euclidean', {}), | ||
| (pairwise_distances, minkowski, _minkowski_kwds), |
There was a problem hiding this comment.
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.
I guess this kind of parametrization should be applied to the 'minkowsi' case too, right?
|
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!