Skip to content

[MRG+2] MAINT: no longer backport graph_laplacian, use scipy one#9077

Merged
lesteve merged 3 commits intoscikit-learn:masterfrom
vene:scipy_laplacian
Jun 9, 2017
Merged

[MRG+2] MAINT: no longer backport graph_laplacian, use scipy one#9077
lesteve merged 3 commits intoscikit-learn:masterfrom
vene:scipy_laplacian

Conversation

@vene
Copy link
Copy Markdown
Member

@vene vene commented Jun 9, 2017

Reference Issue: None

What does this implement/fix? Explain your changes.

Clean-up: our minimum supported scipy (0.13) has a compatible implementation of graph laplacian, so we no longer need to keep a copy in our repo.

Any other comments?

The upstream implementation might have a couple of optimizations compared to ours, but nothing breaking. I kept our test in utils, to have it run once on CI; then I will remove it. I ran the full test suite with scipy 0.13.3 on my machine.

Ping @glemaitre, @jmargeta; helps the debugging scope of #9062


import numpy as np
from scipy import sparse
from scipy.sparse.csgraph import laplacian as graph_laplacian
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyflake raises F401: imported but unused on this line.

However, it is used from other files, just not from this one.

I am inclined to add #noqa and keep providing it this way.

Alternative 2: fix our codebase to directly import from scipy, and provide a thin function here that raises deprecation warnings (in case users are calling this directly.)

after some thought, alternative 2 sounds better. But it was healthy to have a run of CI with this simple commit.



@ignore_warnings(category=DeprecationWarning)
def test_graph_laplacian():
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this test (and this whole file) can go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, the very same test is done in scipy directly https://github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/tests/test_graph_laplacian.py#L61

however, maybe we might want to add tests for the extra math properties of graph Laplacians here (e.g. for a fully connected graph, the first eigenvector is constant) in this file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me, the point of the test currently is simply to check that importing sklearn.utils.graph_laplacian is not broken, because we are still supporting it for two releases. When that import point will go away, the test will fail, reminding us to remove it. I could replace it by a simpler guard test that just imports, checks for deprecation warning, and returns, but this is lazier.

Actual functionality tests for math properties should from now on go into scipy, IMO, unless we find a bug and backport it again.

@vene vene force-pushed the scipy_laplacian branch from 2bbad33 to b7aeff6 Compare June 9, 2017 11:41
@glemaitre
Copy link
Copy Markdown
Member

LGTM

@vene vene changed the title [WIP] MAINT: no longer backport graph_laplacian, use scipy one [MRG] MAINT: no longer backport graph_laplacian, use scipy one Jun 9, 2017
@TomDLT
Copy link
Copy Markdown
Member

TomDLT commented Jun 9, 2017

LGTM

@TomDLT TomDLT changed the title [MRG] MAINT: no longer backport graph_laplacian, use scipy one [MRG+2] MAINT: no longer backport graph_laplacian, use scipy one Jun 9, 2017
@lesteve
Copy link
Copy Markdown
Member

lesteve commented Jun 9, 2017

I pushed a tiny change in the whats_new, merging, thanks a lot!

@lesteve lesteve merged commit 738053e into scikit-learn:master Jun 9, 2017
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants