Skip to content

Commit

Permalink
Non-regression test for scikit-learn#13393 (amg solver stability)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrisel committed Jan 3, 2020
1 parent 4d5407c commit e7b8bff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sklearn/cluster/tests/test_spectral.py
Expand Up @@ -230,6 +230,23 @@ def test_spectral_clustering_with_arpack_amg_solvers():
random_state=0)


def test_spectral_clustering_amg_solver_failure():
# Non-regression test for amg solver failure (issue #13393 on github)
pytest.importorskip('pyamg')
seed = 36
num_nodes = 1000
X = sparse.rand(num_nodes, num_nodes, density=0.1, random_state=seed)
upper = sparse.triu(X) - sparse.diags(X.diagonal())
sym_matrix = upper + upper.T
clustering = SpectralClustering(n_clusters=3,
eigen_solver='amg',
random_state=seed,
affinity='precomputed')

# Smoke test: underlying solver should not raise numpy.linalg.LinAlgError
clustering.fit(sym_matrix)


def test_n_components():
# Test that after adding n_components, result is different and
# n_components = n_clusters by default
Expand Down

0 comments on commit e7b8bff

Please sign in to comment.