@@ -26,9 +26,9 @@ def compute_kernel_slow(Y, X, kernel, h):
2626
2727
2828def  test_kernel_density (n_samples = 100 , n_features = 3 ):
29-     np .random .seed (0 )
30-     X  =  np . random . random (( n_samples , n_features ) )
31-     Y  =  np . random . random (( n_samples , n_features ) )
29+     rng   =   np .random .RandomState (0 )
30+     X  =  rng . randn ( n_samples , n_features )
31+     Y  =  rng . randn ( n_samples , n_features )
3232
3333    for  kernel  in  ['gaussian' , 'tophat' , 'epanechnikov' ,
3434                   'exponential' , 'linear' , 'cosine' ]:
@@ -52,8 +52,8 @@ def check_results(kernel, bandwidth, atol, rtol):
5252
5353
5454def  test_kernel_density_sampling (n_samples = 100 , n_features = 3 ):
55-     np .random .seed (0 )
56-     X  =  np . random . random (( n_samples , n_features ) )
55+     rng   =   np .random .RandomState (0 )
56+     X  =  rng . randn ( n_samples , n_features )
5757
5858    bandwidth  =  0.2 
5959
@@ -80,16 +80,16 @@ def test_kernel_density_sampling(n_samples=100, n_features=3):
8080        assert_raises (NotImplementedError , kde .sample , 100 )
8181
8282    # non-regression test: used to return a scalar 
83-     X  =  np . random . random (( 4 , 1 ) )
83+     X  =  rng . randn ( 4 , 1 )
8484    kde  =  KernelDensity (kernel = "gaussian" ).fit (X )
8585    assert_equal (kde .sample ().shape , (1 , 1 ))
8686
8787
8888def  test_kde_algorithm_metric_choice ():
8989    """Smoke test for various metrics and algorithms""" 
90-     np .random .seed (0 )
91-     X  =  np . random . random (( 10 , 2 ))   # 2 features required for haversine dist. 
92-     Y  =  np . random . random (( 10 , 2 ) )
90+     rng   =   np .random .RandomState (0 )
91+     X  =  rng . randn ( 10 , 2 )     # 2 features required for haversine dist. 
92+     Y  =  rng . randn ( 10 , 2 )
9393
9494    for  algorithm  in  ['auto' , 'ball_tree' , 'kd_tree' ]:
9595        for  metric  in  ['euclidean' , 'minkowski' , 'manhattan' ,
0 commit comments