Skip to content

Commit a4e2bfb

Browse files
authored
MAINT Clean-up some old warning filters (scikit-learn#29460)
1 parent 379a2f1 commit a4e2bfb

File tree

18 files changed

+5
-116
lines changed

18 files changed

+5
-116
lines changed

sklearn/cluster/tests/test_spectral.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,6 @@ def test_discretize(n_samples, coo_container):
215215
assert adjusted_rand_score(y_true, y_pred) > 0.8
216216

217217

218-
# TODO: Remove when pyamg does replaces sp.rand call with np.random.rand
219-
# https://github.com/scikit-learn/scikit-learn/issues/15913
220-
@pytest.mark.filterwarnings(
221-
"ignore:scipy.rand is deprecated:DeprecationWarning:pyamg.*"
222-
)
223-
# TODO: Remove when pyamg removes the use of np.float
224-
@pytest.mark.filterwarnings(
225-
"ignore:`np.float` is a deprecated alias:DeprecationWarning:pyamg.*"
226-
)
227-
# TODO: Remove when pyamg removes the use of pinv2
228-
@pytest.mark.filterwarnings(
229-
"ignore:scipy.linalg.pinv2 is deprecated:DeprecationWarning:pyamg.*"
230-
)
231-
# TODO: Remove when pyamg removes the use of np.find_common_type
232-
@pytest.mark.filterwarnings(
233-
"ignore:np.find_common_type is deprecated:DeprecationWarning:pyamg.*"
234-
)
235218
def test_spectral_clustering_with_arpack_amg_solvers():
236219
# Test that spectral_clustering is the same for arpack and amg solver
237220
# Based on toy example from plot_segmentation_toy.py

sklearn/decomposition/tests/test_factor_analysis.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99
from sklearn.decomposition import FactorAnalysis
1010
from sklearn.decomposition._factor_analysis import _ortho_rotation
1111
from sklearn.exceptions import ConvergenceWarning
12-
from sklearn.utils._testing import (
13-
assert_almost_equal,
14-
assert_array_almost_equal,
15-
ignore_warnings,
16-
)
12+
from sklearn.utils._testing import assert_almost_equal, assert_array_almost_equal
1713

1814

19-
# Ignore warnings from switching to more power iterations in randomized_svd
20-
@ignore_warnings
2115
def test_factor_analysis(global_random_seed):
2216
# Test FactorAnalysis ability to recover the data covariance structure
2317
rng = np.random.RandomState(global_random_seed)

sklearn/ensemble/tests/test_forest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,6 @@ def test_random_trees_dense_equal():
879879
assert_array_equal(X_transformed_sparse.toarray(), X_transformed_dense)
880880

881881

882-
# Ignore warnings from switching to more power iterations in randomized_svd
883-
@ignore_warnings
884882
def test_random_hasher():
885883
# test random forest hashing on circles dataset
886884
# make sure that it is linearly separable.

sklearn/inspection/_plot/tests/test_plot_partial_dependence.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def clf_diabetes(diabetes):
4242
return clf
4343

4444

45-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
4645
@pytest.mark.parametrize("grid_resolution", [10, 20])
4746
def test_plot_partial_dependence(grid_resolution, pyplot, clf_diabetes, diabetes):
4847
# Test partial dependence plot function.
@@ -114,7 +113,6 @@ def test_plot_partial_dependence(grid_resolution, pyplot, clf_diabetes, diabetes
114113
assert ax.get_ylabel() == diabetes.feature_names[2]
115114

116115

117-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
118116
@pytest.mark.parametrize(
119117
"kind, centered, subsample, shape",
120118
[
@@ -164,7 +162,6 @@ def test_plot_partial_dependence_kind(
164162
assert all([ln._y[0] != 0.0 for ln in disp.lines_.ravel() if ln is not None])
165163

166164

167-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
168165
@pytest.mark.parametrize(
169166
"input_type, feature_names_type",
170167
[
@@ -252,7 +249,6 @@ def test_plot_partial_dependence_str_features(
252249
assert ax.get_ylabel() == "bmi"
253250

254251

255-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
256252
def test_plot_partial_dependence_custom_axes(pyplot, clf_diabetes, diabetes):
257253
grid_resolution = 25
258254
fig, (ax1, ax2) = pyplot.subplots(1, 2)
@@ -288,7 +284,6 @@ def test_plot_partial_dependence_custom_axes(pyplot, clf_diabetes, diabetes):
288284
assert ax.get_ylabel() == "bmi"
289285

290286

291-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
292287
@pytest.mark.parametrize(
293288
"kind, lines", [("average", 1), ("individual", 50), ("both", 51)]
294289
)
@@ -329,7 +324,6 @@ def test_plot_partial_dependence_passing_numpy_axes(
329324
assert len(disp2.axes_[0, 1].get_lines()) == 2 * lines
330325

331326

332-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
333327
@pytest.mark.parametrize("nrows, ncols", [(2, 2), (3, 1)])
334328
def test_plot_partial_dependence_incorrent_num_axes(
335329
pyplot, clf_diabetes, diabetes, nrows, ncols
@@ -364,7 +358,6 @@ def test_plot_partial_dependence_incorrent_num_axes(
364358
disp.plot(ax=ax_format)
365359

366360

367-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
368361
def test_plot_partial_dependence_with_same_axes(pyplot, clf_diabetes, diabetes):
369362
# The first call to plot_partial_dependence will create two new axes to
370363
# place in the space of the passed in axes, which results in a total of
@@ -404,7 +397,6 @@ def test_plot_partial_dependence_with_same_axes(pyplot, clf_diabetes, diabetes):
404397
)
405398

406399

407-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
408400
def test_plot_partial_dependence_feature_name_reuse(pyplot, clf_diabetes, diabetes):
409401
# second call to plot does not change the feature names from the first
410402
# call
@@ -426,7 +418,6 @@ def test_plot_partial_dependence_feature_name_reuse(pyplot, clf_diabetes, diabet
426418
assert ax.get_xlabel() == feature_names[i]
427419

428420

429-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
430421
def test_plot_partial_dependence_multiclass(pyplot):
431422
grid_resolution = 25
432423
clf_int = GradientBoostingClassifier(n_estimators=10, random_state=1)
@@ -480,7 +471,6 @@ def test_plot_partial_dependence_multiclass(pyplot):
480471
multioutput_regression_data = make_regression(n_samples=50, n_targets=2, random_state=0)
481472

482473

483-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
484474
@pytest.mark.parametrize("target", [0, 1])
485475
def test_plot_partial_dependence_multioutput(pyplot, target):
486476
# Test partial dependence plot function on multi-output input.
@@ -506,7 +496,6 @@ def test_plot_partial_dependence_multioutput(pyplot, target):
506496
assert ax.get_xlabel() == f"x{i}"
507497

508498

509-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
510499
def test_plot_partial_dependence_dataframe(pyplot, clf_diabetes, diabetes):
511500
pd = pytest.importorskip("pandas")
512501
df = pd.DataFrame(diabetes.data, columns=diabetes.feature_names)
@@ -525,7 +514,6 @@ def test_plot_partial_dependence_dataframe(pyplot, clf_diabetes, diabetes):
525514
dummy_classification_data = make_classification(random_state=0)
526515

527516

528-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
529517
@pytest.mark.parametrize(
530518
"data, params, err_msg",
531519
[
@@ -619,7 +607,6 @@ def test_plot_partial_dependence_error(pyplot, data, params, err_msg):
619607
PartialDependenceDisplay.from_estimator(estimator, X, **params)
620608

621609

622-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
623610
@pytest.mark.parametrize(
624611
"params, err_msg",
625612
[
@@ -982,7 +969,6 @@ def test_partial_dependence_kind_error(
982969
)
983970

984971

985-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
986972
@pytest.mark.parametrize(
987973
"line_kw, pd_line_kw, ice_lines_kw, expected_colors",
988974
[

sklearn/inspection/tests/test_partial_dependence.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ def fit(self, X, y):
480480
return self
481481

482482

483-
@pytest.mark.filterwarnings("ignore:A Bunch will be returned")
484483
@pytest.mark.parametrize(
485484
"estimator, params, err_msg",
486485
[

sklearn/linear_model/tests/test_least_angle.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,20 @@ def test_all_precomputed():
117117
assert_array_almost_equal(expected, got)
118118

119119

120+
# TODO: remove warning filter when numpy min version >= 2.0.0
120121
@pytest.mark.filterwarnings("ignore: `rcond` parameter will change")
121-
# numpy deprecation
122122
def test_lars_lstsq():
123123
# Test that Lars gives least square solution at the end
124124
# of the path
125125
X1 = 3 * X # use un-normalized dataset
126126
clf = linear_model.LassoLars(alpha=0.0)
127127
clf.fit(X1, y)
128-
coef_lstsq = np.linalg.lstsq(X1, y, rcond=None)[0]
128+
coef_lstsq = np.linalg.lstsq(X1, y)[0]
129129
assert_array_almost_equal(clf.coef_, coef_lstsq)
130130

131131

132-
@pytest.mark.filterwarnings("ignore:`rcond` parameter will change")
133-
# numpy deprecation
132+
# TODO: remove warning filter when numpy min version >= 2.0.0
133+
@pytest.mark.filterwarnings("ignore: `rcond` parameter will change")
134134
def test_lasso_gives_lstsq_solution():
135135
# Test that Lars Lasso gives least square solution at the end
136136
# of the path
@@ -408,7 +408,6 @@ def test_lars_n_nonzero_coefs(verbose=False):
408408
assert len(lars.alphas_) == 7
409409

410410

411-
@ignore_warnings
412411
def test_multitarget():
413412
# Assure that estimators receiving multidimensional y do the right thing
414413
Y = np.vstack([y, y**2]).T

sklearn/linear_model/tests/test_sgd.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
assert_almost_equal,
2626
assert_array_almost_equal,
2727
assert_array_equal,
28-
ignore_warnings,
2928
)
3029

3130

@@ -1365,7 +1364,6 @@ def test_elasticnet_convergence(klass):
13651364
assert_almost_equal(cd.coef_, sgd.coef_, decimal=2, err_msg=err_msg)
13661365

13671366

1368-
@ignore_warnings
13691367
@pytest.mark.parametrize("klass", [SGDRegressor, SparseSGDRegressor])
13701368
def test_partial_fit(klass):
13711369
third = X.shape[0] // 3

sklearn/manifold/tests/test_spectral_embedding.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,6 @@ def test_spectral_embedding_callable_affinity(sparse_container, seed=36):
244244
_assert_equal_with_sign_flipping(embed_rbf, embed_callable, 0.05)
245245

246246

247-
# TODO: Remove when pyamg does replaces sp.rand call with np.random.rand
248-
# https://github.com/scikit-learn/scikit-learn/issues/15913
249-
@pytest.mark.filterwarnings(
250-
"ignore:scipy.rand is deprecated:DeprecationWarning:pyamg.*"
251-
)
252-
# TODO: Remove when pyamg removes the use of np.float
253-
@pytest.mark.filterwarnings(
254-
"ignore:`np.float` is a deprecated alias:DeprecationWarning:pyamg.*"
255-
)
256-
# TODO: Remove when pyamg removes the use of pinv2
257-
@pytest.mark.filterwarnings(
258-
"ignore:scipy.linalg.pinv2 is deprecated:DeprecationWarning:pyamg.*"
259-
)
260-
@pytest.mark.filterwarnings(
261-
"ignore:np.find_common_type is deprecated:DeprecationWarning:pyamg.*"
262-
)
263247
@pytest.mark.skipif(
264248
not pyamg_available, reason="PyAMG is required for the tests in this function."
265249
)
@@ -319,27 +303,9 @@ def test_spectral_embedding_amg_solver(dtype, coo_container, seed=36):
319303
se_amg.fit_transform(affinity)
320304

321305

322-
# TODO: Remove filterwarnings when pyamg does replaces sp.rand call with
323-
# np.random.rand:
324-
# https://github.com/scikit-learn/scikit-learn/issues/15913
325-
@pytest.mark.filterwarnings(
326-
"ignore:scipy.rand is deprecated:DeprecationWarning:pyamg.*"
327-
)
328-
# TODO: Remove when pyamg removes the use of np.float
329-
@pytest.mark.filterwarnings(
330-
"ignore:`np.float` is a deprecated alias:DeprecationWarning:pyamg.*"
331-
)
332-
# TODO: Remove when pyamg removes the use of pinv2
333-
@pytest.mark.filterwarnings(
334-
"ignore:scipy.linalg.pinv2 is deprecated:DeprecationWarning:pyamg.*"
335-
)
336306
@pytest.mark.skipif(
337307
not pyamg_available, reason="PyAMG is required for the tests in this function."
338308
)
339-
# TODO: Remove when pyamg removes the use of np.find_common_type
340-
@pytest.mark.filterwarnings(
341-
"ignore:np.find_common_type is deprecated:DeprecationWarning:pyamg.*"
342-
)
343309
@pytest.mark.parametrize("dtype", (np.float32, np.float64))
344310
def test_spectral_embedding_amg_solver_failure(dtype, seed=36):
345311
# Non-regression test for amg solver failure (issue #13393 on github)
@@ -360,7 +326,6 @@ def test_spectral_embedding_amg_solver_failure(dtype, seed=36):
360326
_assert_equal_with_sign_flipping(embedding, new_embedding, tol=0.05)
361327

362328

363-
@pytest.mark.filterwarnings("ignore:the behavior of nmi will change in version 0.22")
364329
def test_pipeline_spectral_clustering(seed=36):
365330
# Test using pipeline to do spectral clustering
366331
random_state = np.random.RandomState(seed)
@@ -509,10 +474,6 @@ def test_error_pyamg_not_available():
509474
se_precomp.fit_transform(S)
510475

511476

512-
# TODO: Remove when pyamg removes the use of np.find_common_type
513-
@pytest.mark.filterwarnings(
514-
"ignore:np.find_common_type is deprecated:DeprecationWarning:pyamg.*"
515-
)
516477
@pytest.mark.parametrize("solver", ["arpack", "amg", "lobpcg"])
517478
@pytest.mark.parametrize("csr_container", CSR_CONTAINERS)
518479
def test_spectral_eigen_tol_auto(monkeypatch, solver, csr_container):

sklearn/metrics/cluster/tests/test_common.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def test_symmetric_non_symmetric_union():
9696
)
9797

9898

99-
# 0.22 AMI and NMI changes
100-
@pytest.mark.filterwarnings("ignore::FutureWarning")
10199
@pytest.mark.parametrize(
102100
"metric_name, y1, y2", [(name, y1, y2) for name in SYMMETRIC_METRICS]
103101
)
@@ -114,8 +112,6 @@ def test_non_symmetry(metric_name, y1, y2):
114112
assert metric(y1, y2) != pytest.approx(metric(y2, y1))
115113

116114

117-
# 0.22 AMI and NMI changes
118-
@pytest.mark.filterwarnings("ignore::FutureWarning")
119115
@pytest.mark.parametrize("metric_name", NORMALIZED_METRICS)
120116
def test_normalized_output(metric_name):
121117
upper_bound_1 = [0, 0, 0, 1, 1, 1]
@@ -135,8 +131,6 @@ def test_normalized_output(metric_name):
135131
assert not (score < 0).any()
136132

137133

138-
# 0.22 AMI and NMI changes
139-
@pytest.mark.filterwarnings("ignore::FutureWarning")
140134
@pytest.mark.parametrize("metric_name", chain(SUPERVISED_METRICS, UNSUPERVISED_METRICS))
141135
def test_permute_labels(metric_name):
142136
# All clustering metrics do not change score due to permutations of labels
@@ -156,8 +150,6 @@ def test_permute_labels(metric_name):
156150
assert_allclose(score_1, metric(X, 1 - y_pred))
157151

158152

159-
# 0.22 AMI and NMI changes
160-
@pytest.mark.filterwarnings("ignore::FutureWarning")
161153
@pytest.mark.parametrize("metric_name", chain(SUPERVISED_METRICS, UNSUPERVISED_METRICS))
162154
# For all clustering metrics Input parameters can be both
163155
# in the form of arrays lists, positive, negative or string

sklearn/metrics/tests/test_score_objects.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ def test_supervised_cluster_scorers():
551551
assert_almost_equal(score1, score2)
552552

553553

554-
@ignore_warnings
555554
def test_raises_on_score_list():
556555
# Test that when a list of scores is returned, we raise proper errors.
557556
X, y = make_blobs(random_state=0)
@@ -566,7 +565,6 @@ def test_raises_on_score_list():
566565
grid_search.fit(X, y)
567566

568567

569-
@ignore_warnings
570568
def test_classification_scorer_sample_weight():
571569
# Test that classification scorers support sample_weight or raise sensible
572570
# errors
@@ -626,7 +624,6 @@ def test_classification_scorer_sample_weight():
626624
)
627625

628626

629-
@ignore_warnings
630627
def test_regression_scorer_sample_weight():
631628
# Test that regression scorers support sample_weight or raise sensible
632629
# errors

0 commit comments

Comments
 (0)