TST Convert warnings into errors in test_affinity_propgation
@@ -156,11 +156,11 @@ def test_affinity_propagation_equal_mutual_similarities():
assert_array_equal([0, 0], labels)
# setting different preferences
- with warnings.catch_warnings(record=True) as record:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", UserWarning)
cluster_center_indices, labels = affinity_propagation(
S, preference=[-20, -10], random_state=37
)
- assert not [w.message for w in record]
# expect one cluster, with highest-preference sample as exemplar
assert_array_equal([1], cluster_center_indices)
@@ -247,9 +247,9 @@ def test_affinity_propagation_convergence_warning_dense_sparse(centers):
ap = AffinityPropagation(random_state=46)
ap.fit(X, y)
ap.cluster_centers_ = centers
- with warnings.catch_warnings(record=True) as record:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", ConvergenceWarning)
assert_array_equal(ap.predict(X), np.zeros(X.shape[0], dtype=int))
- assert not [w.message for w in record]
def test_affinity_propagation_float32():
