@@ -176,10 +176,10 @@ def test_agglomerative_clustering_distances(
176
176
assert not hasattr (clustering , "distances_" )
177
177
178
178
179
- def test_agglomerative_clustering ():
179
+ def test_agglomerative_clustering (global_random_seed ):
180
180
# Check that we obtain the correct number of clusters with
181
181
# agglomerative clustering.
182
- rng = np .random .RandomState (0 )
182
+ rng = np .random .RandomState (global_random_seed )
183
183
mask = np .ones ([10 , 10 ], dtype = bool )
184
184
n_samples = 100
185
185
X = rng .randn (n_samples , 50 )
@@ -280,9 +280,9 @@ def test_agglomerative_clustering_memory_mapped():
280
280
AgglomerativeClustering (metric = "euclidean" , linkage = "single" ).fit (Xmm )
281
281
282
282
283
- def test_ward_agglomeration ():
283
+ def test_ward_agglomeration (global_random_seed ):
284
284
# Check that we obtain the correct solution in a simplistic case
285
- rng = np .random .RandomState (0 )
285
+ rng = np .random .RandomState (global_random_seed )
286
286
mask = np .ones ([10 , 10 ], dtype = bool )
287
287
X = rng .randn (50 , 100 )
288
288
connectivity = grid_to_graph (* mask .shape )
@@ -330,10 +330,10 @@ def assess_same_labelling(cut1, cut2):
330
330
assert (co_clust [0 ] == co_clust [1 ]).all ()
331
331
332
332
333
- def test_sparse_scikit_vs_scipy ():
333
+ def test_sparse_scikit_vs_scipy (global_random_seed ):
334
334
# Test scikit linkage with full connectivity (i.e. unstructured) vs scipy
335
335
n , p , k = 10 , 5 , 3
336
- rng = np .random .RandomState (0 )
336
+ rng = np .random .RandomState (global_random_seed )
337
337
338
338
# Not using a lil_matrix here, just to check that non sparse
339
339
# matrices are well handled
@@ -370,10 +370,9 @@ def test_sparse_scikit_vs_scipy():
370
370
371
371
# Make sure our custom mst_linkage_core gives
372
372
# the same results as scipy's builtin
373
- @pytest .mark .parametrize ("seed" , range (5 ))
374
- def test_vector_scikit_single_vs_scipy_single (seed ):
373
+ def test_vector_scikit_single_vs_scipy_single (global_random_seed ):
375
374
n_samples , n_features , n_clusters = 10 , 5 , 3
376
- rng = np .random .RandomState (seed )
375
+ rng = np .random .RandomState (global_random_seed )
377
376
X = 0.1 * rng .normal (size = (n_samples , n_features ))
378
377
X -= 4.0 * np .arange (n_samples )[:, np .newaxis ]
379
378
X -= X .mean (axis = 1 )[:, np .newaxis ]
@@ -468,13 +467,13 @@ def test_connectivity_propagation():
468
467
ward .fit (X )
469
468
470
469
471
- def test_ward_tree_children_order ():
470
+ def test_ward_tree_children_order (global_random_seed ):
472
471
# Check that children are ordered in the same way for both structured and
473
472
# unstructured versions of ward_tree.
474
473
475
474
# test on five random datasets
476
475
n , p = 10 , 5
477
- rng = np .random .RandomState (0 )
476
+ rng = np .random .RandomState (global_random_seed )
478
477
479
478
connectivity = np.ones ((n , n ))
480
479
for i in range (5 ):
@@ -488,13 +487,13 @@ def test_ward_tree_children_order():
488
487
assert_array_equal (out_unstructured [0 ], out_structured [0 ])
489
488
490
489
491
- def test_ward_linkage_tree_return_distance ():
490
+ def test_ward_linkage_tree_return_distance (global_random_seed ):
492
491
# Test return_distance option on linkage and ward trees
493
492
494
493
# test that return_distance when set true, gives same
495
494
# output on both structured and unstructured clustering.
496
495
n , p = 10 , 5
497
- rng = np .random .RandomState (0 )
496
+ rng = np .random .RandomState (global_random_seed )
498
497
499
498
connectivity = np .ones ((n , n ))
500
499
for i in range (5 ):
@@ -726,10 +725,10 @@ def increment(self, *args, **kwargs):
726
725
727
726
728
727
@pytest .mark .parametrize ("linkage" , ["ward" , "complete" , "average" ])
729
- def test_agglomerative_clustering_with_distance_threshold (linkage ):
728
+ def test_agglomerative_clustering_with_distance_threshold (linkage , global_random_seed ):
730
729
# Check that we obtain the correct number of clusters with
731
730
# agglomerative clustering with distance_threshold.
732
- rng = np .random .RandomState (0 )
731
+ rng = np .random .RandomState (global_random_seed )
733
732
mask = np .ones ([10 , 10 ], dtype = bool )
734
733
n_samples = 100
735
734
X = rng .randn (n_samples , 50 )
@@ -764,8 +763,8 @@ def test_agglomerative_clustering_with_distance_threshold(linkage):
764
763
assert np .array_equiv (clusters_produced , clusters_at_threshold )
765
764
766
765
767
- def test_small_distance_threshold ():
768
- rng = np .random .RandomState (0 )
766
+ def test_small_distance_threshold (global_random_seed ):
767
+ rng = np .random .RandomState (global_random_seed )
769
768
n_samples = 10
770
769
X = rng .randint (- 300 , 300 , size = (n_samples , 3 ))
771
770
# this should result in all data in their own clusters, given that
@@ -781,8 +780,8 @@ def test_small_distance_threshold():
781
780
assert clustering .n_clusters_ == n_samples
782
781
783
782
784
- def test_cluster_distances_with_distance_threshold ():
785
- rng = np .random .RandomState (0 )
783
+ def test_cluster_distances_with_distance_threshold (global_random_seed ):
784
+ rng = np .random .RandomState (global_random_seed )
786
785
n_samples = 100
787
786
X = rng .randint (- 10 , 10 , size = (n_samples , 3 ))
788
787
# check the distances within the clusters and with other clusters
0 commit comments