|
43 | 43 | from sklearn.svm.base import BaseLibSVM |
44 | 44 |
|
45 | 45 | from sklearn.cross_validation import train_test_split |
| 46 | +from sklearn.utils.validation import DataConversionWarning |
46 | 47 |
|
47 | 48 | dont_test = ['SparseCoder', 'EllipticEnvelope', 'EllipticEnvelop', |
48 | 49 | 'DictVectorizer', 'LabelBinarizer', 'LabelEncoder', |
@@ -495,7 +496,6 @@ def test_clustering(): |
495 | 496 | continue |
496 | 497 | # catch deprecation and neighbors warnings |
497 | 498 | with warnings.catch_warnings(record=True): |
498 | | - warnings.simplefilter("always") |
499 | 499 | alg = Alg() |
500 | 500 | if hasattr(alg, "n_clusters"): |
501 | 501 | alg.set_params(n_clusters=3) |
@@ -663,9 +663,12 @@ def test_classifiers_input_shapes(): |
663 | 663 |
|
664 | 664 | set_random_state(classifier) |
665 | 665 | classifier.fit(X, y[:, np.newaxis]) |
| 666 | + # Check that when a 2D y is given, a DataConversionWarning is |
| 667 | + # raised |
666 | 668 | with warnings.catch_warnings(record=True) as w: |
| 669 | + warnings.simplefilter("always", DataConversionWarning) |
667 | 670 | classifier.fit(X, y[:, np.newaxis]) |
668 | | - print(w) |
| 671 | + assert_equal(len(w), 1) |
669 | 672 | assert_array_equal(y_pred, classifier.predict(X)) |
670 | 673 |
|
671 | 674 |
|
|
0 commit comments