| 
 | 1 | +import warnings  | 
 | 2 | + | 
1 | 3 | from nose.tools import assert_true  | 
2 | 4 | from nose.tools import assert_equal  | 
3 | 5 | 
 
  | 
@@ -64,11 +66,22 @@ def test_spectral_embedding_two_components(seed=36):  | 
64 | 66 | 
 
  | 
65 | 67 |     se_precomp = SpectralEmbedding(n_components=1, affinity="precomputed",  | 
66 | 68 |                                    random_state=np.random.RandomState(seed))  | 
67 |  | -    embedded_corrdinate = np.squeeze(se_precomp.fit_transform(affinity))  | 
 | 69 | +    embedded_coordinate = se_precomp.fit_transform(affinity)  | 
68 | 70 |     # thresholding on the first components using 0.  | 
69 |  | -    label_ = np.array(embedded_corrdinate < 0, dtype="float")  | 
 | 71 | +    label_ = np.array(embedded_coordinate.ravel() < 0, dtype="float")  | 
70 | 72 |     assert_equal(normalized_mutual_info_score(true_label, label_), 1.0)  | 
71 | 73 | 
 
  | 
 | 74 | +    # test that we can still import spectral embedding  | 
 | 75 | + | 
 | 76 | +    from sklearn.cluster import spectral_embedding as se_deprecated  | 
 | 77 | +    with warnings.catch_warnings(record=True) as warning_list:  | 
 | 78 | +        embedded_depr = se_deprecated(affinity, n_components=1,  | 
 | 79 | +                                      random_state=np.random.RandomState(seed))  | 
 | 80 | +    assert_equal(len(warning_list), 1)  | 
 | 81 | + | 
 | 82 | +    assert_true(_check_with_col_sign_flipping(embedded_coordinate,  | 
 | 83 | +                                              embedded_depr, 0.01))  | 
 | 84 | + | 
72 | 85 | 
 
  | 
73 | 86 | def test_spectral_embedding_precomputed_affinity(seed=36):  | 
74 | 87 |     """Test spectral embedding with precomputed kernel"""  | 
 | 
0 commit comments