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
TST Extend tests for scipy.sparse.*array
in sklearn/cluster/tests/test_spectral.py
#27161
Conversation
Extend tests for scipy.sparse.*array
in sklearn/cluster/tests/test_spectral.py
Extend tests for
scipy.sparse.*array in
sklearn/cluster/tests/test_spectral.py`
Extend tests for
scipy.sparse.*array in
sklearn/cluster/tests/test_spectral.py`scipy.sparse.*array
in sklearn/cluster/tests/test_spectral.py
No, this |
I believe that one way to achieve that would be to rewrite: w = m.sum(axis=axis).getA1() - m.diagonal() as: # np.asarray + ravel is used for backward compat for scipy sparse matrix while making
# it also work with the scipy sparse array API.
w = np.asarray(m.sum(axis=axis)).ravel() - m.diagonal() |
Since this PR will actually fix the code of the |
If we decide to rewrite this, won't this still need to be done in scipy itself? (As the |
Indeed you are right. I read your analysis too quickly. Apparently, this code is still the same in the https://github.com/scipy/scipy/blob/main/scipy/sparse/csgraph/_laplacian.py#L459 and I could not find any related issue by doing a quick search. Let me report it there. |
Done in scipy/scipy#19149. @bharatr21 depending on the feedback of scipy maintainers, feel free to open a PR upstream. Once accepted we will have to see how to do a backport or workaround in scikit-learn. |
Raised the PR: scipy/scipy#19156. Let's wait and see what happens there. |
UPDATE: The above PR in scipy/scipy#19156 is now merged |
I don't think it's worth backporting a temporary fix to scikit-learn. I think we can just mark the tests as xfail based on the version of scipy (that is |
Note that is probably easier to use https://docs.pytest.org/en/6.2.x/skipping.html#xfail-mark-test-functions-as-expected-to-fail We should only call |
And by the way, thanks @bharatr21 for fixing the bug upstream! |
Uhm, I see that we have the same problem that I earlier encounter today (kudos to @bharatr21 for fixing the bug upstream): #27240 @ogrisel I was proposing to vendor the |
I am fine with this option then. |
Don't totally get this, what does "vendoring" a file mean? Importing some specific version in |
Making a local copy of the full file in scikit-learn. (Typically under sklear.externals._private_module_name) and exposing the fraction the api we want to use under sklearn.fixes. we do this for the parse_version method of the packaging module for instance. |
Alternatively, we could skip all spectral related tests with scipy sparse array based on the version of scipy. |
The vendoring is already going in #27240 |
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 modulo an potential changelog entry adaptation. Thank you @bharatr21.
The fix mentioned by @glemaitre has been integrated in between, resolving the failure here after merging main
.
May I know in which changelog I should make the entry? Is it still |
Still not sure what to put in the changelog since these 2 entries are already present - :func:`manifold.spectral_embedding` in :pr:`27240` by :user:`Yao Xiao <Charlie-XIAO>`;
- :func:`manifold.SpectralEmbedding` in :pr:`27240` by :user:`Yao Xiao <Charlie-XIAO>`; @jjerphan please re-review the changelog entry (I'm not sure if it's necessary since there's no code changes?) |
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 probably are going to adapt the changelog entry anyway.
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. Thanks @bharatr21
Reference Issues/PRs
Towards #27090
What does this implement/fix? Explain your changes.
Extends tests for
scipy.sparse.*array
Any other comments?
I am aware of the test failures, a sample failure is this one:
All the failures seem to be occurring due to an upstream issue in scipy here
Should we raise an issue/bug upstream in
scipy
? Or attempt some other alternative fix from our end?