diff --git a/sklearn/linear_model/tests/test_least_angle.py b/sklearn/linear_model/tests/test_least_angle.py index 8b6f939c67d69..eaa99d11e7844 100644 --- a/sklearn/linear_model/tests/test_least_angle.py +++ b/sklearn/linear_model/tests/test_least_angle.py @@ -370,7 +370,7 @@ def test_multitarget(): for estimator in (linear_model.LassoLars(), linear_model.Lars()): estimator.fit(X, Y) Y_pred = estimator.predict(X) - Y_dec = estimator.decision_function(X) + Y_dec = assert_warns(DeprecationWarning, estimator.decision_function, X) assert_array_almost_equal(Y_pred, Y_dec) alphas, active, coef, path = (estimator.alphas_, estimator.active_, estimator.coef_, estimator.coef_path_) diff --git a/sklearn/linear_model/tests/test_sgd.py b/sklearn/linear_model/tests/test_sgd.py index 21a3899d3eb8a..55e68fc77f85a 100644 --- a/sklearn/linear_model/tests/test_sgd.py +++ b/sklearn/linear_model/tests/test_sgd.py @@ -1040,7 +1040,7 @@ def test_partial_fit(self): clf.partial_fit(X[:third], Y[:third]) assert_equal(clf.coef_.shape, (X.shape[1], )) assert_equal(clf.intercept_.shape, (1,)) - assert_equal(clf.decision_function([[0, 0]]).shape, (1, )) + assert_equal(clf.predict([[0, 0]]).shape, (1, )) id1 = id(clf.coef_.data) clf.partial_fit(X[third:], Y[third:]) diff --git a/sklearn/neighbors/tests/test_approximate.py b/sklearn/neighbors/tests/test_approximate.py index 7e32fa130a130..f45aed658bb59 100644 --- a/sklearn/neighbors/tests/test_approximate.py +++ b/sklearn/neighbors/tests/test_approximate.py @@ -39,7 +39,7 @@ def test_neighbors_accuracy_with_n_candidates(): for i, n_candidates in enumerate(n_candidates_values): lshf = LSHForest(n_candidates=n_candidates) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) for j in range(n_iter): query = X[rng.randint(0, n_samples)].reshape(1, -1) @@ -74,7 +74,7 @@ def test_neighbors_accuracy_with_n_estimators(): for i, t in enumerate(n_estimators): lshf = LSHForest(n_candidates=500, n_estimators=t) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) for j in range(n_iter): query = X[rng.randint(0, n_samples)].reshape(1, -1) neighbors = lshf.kneighbors(query, n_neighbors=n_points, @@ -111,7 +111,7 @@ def test_kneighbors(): # Test unfitted estimator assert_raises(ValueError, lshf.kneighbors, X[0]) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) for i in range(n_iter): n_neighbors = rng.randint(0, n_samples) @@ -162,7 +162,7 @@ def test_radius_neighbors(): # Test unfitted estimator assert_raises(ValueError, lshf.radius_neighbors, X[0]) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) for i in range(n_iter): # Select a random point in the dataset as the query @@ -218,6 +218,7 @@ def test_radius_neighbors(): sorted_dists_approx))) +@ignore_warnings def test_radius_neighbors_boundary_handling(): X = [[0.999, 0.001], [0.5, 0.5], [0, 1.], [-1., 0.001]] n_points = len(X) @@ -286,7 +287,7 @@ def test_distances(): X = rng.rand(n_samples, n_features) lshf = LSHForest() - lshf.fit(X) + ignore_warnings(lshf.fit)(X) for i in range(n_iter): n_neighbors = rng.randint(0, n_samples) @@ -312,7 +313,7 @@ def test_fit(): X = rng.rand(n_samples, n_features) lshf = LSHForest(n_estimators=n_estimators) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) # _input_array = X assert_array_equal(X, lshf._fit_X) @@ -343,16 +344,16 @@ def test_partial_fit(): lshf = LSHForest() # Test unfitted estimator - lshf.partial_fit(X) + ignore_warnings(lshf.partial_fit)(X) assert_array_equal(X, lshf._fit_X) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) # Insert wrong dimension assert_raises(ValueError, lshf.partial_fit, np.random.randn(n_samples_partial_fit, n_features - 1)) - lshf.partial_fit(X_partial_fit) + ignore_warnings(lshf.partial_fit)(X_partial_fit) # size of _input_array = samples + 1 after insertion assert_equal(lshf._fit_X.shape[0], @@ -379,7 +380,7 @@ def test_hash_functions(): lshf = LSHForest(n_estimators=n_estimators, random_state=rng.randint(0, np.iinfo(np.int32).max)) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) hash_functions = [] for i in range(n_estimators): @@ -405,7 +406,7 @@ def test_candidates(): # For zero candidates lshf = LSHForest(min_hash_match=32) - lshf.fit(X_train) + ignore_warnings(lshf.fit)(X_train) message = ("Number of candidates is not sufficient to retrieve" " %i neighbors with" @@ -419,7 +420,7 @@ def test_candidates(): # For candidates less than n_neighbors lshf = LSHForest(min_hash_match=31) - lshf.fit(X_train) + ignore_warnings(lshf.fit)(X_train) message = ("Number of candidates is not sufficient to retrieve" " %i neighbors with" @@ -441,7 +442,7 @@ def test_graphs(): for n_samples in n_samples_sizes: X = rng.rand(n_samples, n_features) lshf = LSHForest(min_hash_match=0) - lshf.fit(X) + ignore_warnings(lshf.fit)(X) kneighbors_graph = lshf.kneighbors_graph(X) radius_neighbors_graph = lshf.radius_neighbors_graph(X) diff --git a/sklearn/svm/tests/test_sparse.py b/sklearn/svm/tests/test_sparse.py index 88a3c300f517b..75a33fba5055f 100644 --- a/sklearn/svm/tests/test_sparse.py +++ b/sklearn/svm/tests/test_sparse.py @@ -63,7 +63,7 @@ def check_svm_model_equal(dense_svm, sparse_svm, X_train, y_train, X_test): msg = "cannot use sparse input in 'OneClassSVM' trained on dense data" else: assert_array_almost_equal(dense_svm.predict_proba(X_test_dense), - sparse_svm.predict_proba(X_test), 4) + sparse_svm.predict_proba(X_test), 4) msg = "cannot use sparse input in 'SVC' trained on dense data" if sparse.isspmatrix(X_test): assert_raise_message(ValueError, msg, dense_svm.predict, X_test) diff --git a/sklearn/svm/tests/test_svm.py b/sklearn/svm/tests/test_svm.py index 1855c7e52ebea..d6c52e4496a1f 100644 --- a/sklearn/svm/tests/test_svm.py +++ b/sklearn/svm/tests/test_svm.py @@ -354,10 +354,9 @@ def test_decision_function_shape(): assert_equal(dec.shape, (len(X_train), 10)) -@ignore_warnings -def test_svr_decision_function(): +def test_svr_predict(): # Test SVR's decision_function - # Sanity check, test that decision_function implemented in python + # Sanity check, test that predict implemented in python # returns the same as the one in libsvm X = iris.data @@ -367,14 +366,14 @@ def test_svr_decision_function(): reg = svm.SVR(kernel='linear', C=0.1).fit(X, y) dec = np.dot(X, reg.coef_.T) + reg.intercept_ - assert_array_almost_equal(dec.ravel(), reg.decision_function(X).ravel()) + assert_array_almost_equal(dec.ravel(), reg.predict(X).ravel()) # rbf kernel reg = svm.SVR(kernel='rbf', gamma=1).fit(X, y) rbfs = rbf_kernel(X, reg.support_vectors_, gamma=reg.gamma) dec = np.dot(rbfs, reg.dual_coef_.T) + reg.intercept_ - assert_array_almost_equal(dec.ravel(), reg.decision_function(X).ravel()) + assert_array_almost_equal(dec.ravel(), reg.predict(X).ravel()) def test_weight():