3232ipopt_available = SolverFactory ("ipopt" ).available ()
3333pynumero_ASL_available = AmplInterface .available ()
3434testdir = this_file_dir ()
35- SET_GLOBAL_SEED = True
3635
37- if SET_GLOBAL_SEED :
38- # Set the global seed for reproducibility
39- seed = 524
40- np .random .seed (seed ) # Set seed for reproducibility
36+ # Set the global seed for reproducibility
37+ _RANDOM_SEED_FOR_TESTING = 524
38+ np .random .seed (_RANDOM_SEED_FOR_TESTING ) # Set seed for reproducibility
4139
4240
4341@unittest .skipIf (
@@ -100,7 +98,7 @@ def test_bootstrap(self):
10098
10199 num_bootstraps = 10
102100 theta_est = self .pest .theta_est_bootstrap (
103- num_bootstraps , return_samples = True , seed = seed
101+ num_bootstraps , return_samples = True , seed = _RANDOM_SEED_FOR_TESTING
104102 )
105103
106104 num_samples = theta_est ["samples" ].apply (len )
@@ -117,10 +115,14 @@ def test_bootstrap(self):
117115 self .assertEqual (CR [0.75 ].sum (), 7 )
118116 self .assertEqual (CR [1.0 ].sum (), 10 ) # all true
119117
120- graphics .pairwise_plot (theta_est , seed = seed )
121- graphics .pairwise_plot (theta_est , thetavals , seed = seed )
118+ graphics .pairwise_plot (theta_est , seed = _RANDOM_SEED_FOR_TESTING )
119+ graphics .pairwise_plot (theta_est , thetavals , seed = _RANDOM_SEED_FOR_TESTING )
122120 graphics .pairwise_plot (
123- theta_est , thetavals , 0.8 , ["MVN" , "KDE" , "Rect" ], seed = seed
121+ theta_est ,
122+ thetavals ,
123+ 0.8 ,
124+ ["MVN" , "KDE" , "Rect" ],
125+ seed = _RANDOM_SEED_FOR_TESTING ,
124126 )
125127
126128 @unittest .skipIf (
@@ -150,7 +152,7 @@ def test_leaveNout(self):
150152 self .assertTrue (lNo_theta .shape == (6 , 2 ))
151153
152154 results = self .pest .leaveNout_bootstrap_test (
153- 1 , None , 3 , "Rect" , [0.5 , 1.0 ], seed = 5436
155+ 1 , None , 3 , "Rect" , [0.5 , 1.0 ], seed = _RANDOM_SEED_FOR_TESTING
154156 )
155157 self .assertEqual (len (results ), 6 ) # 6 lNo samples
156158 i = 1
@@ -1150,7 +1152,7 @@ def test_leaveNout(self):
11501152 self .assertTrue (lNo_theta .shape == (6 , 2 ))
11511153
11521154 results = self .pest .leaveNout_bootstrap_test (
1153- 1 , None , 3 , "Rect" , [0.5 , 1.0 ], seed = 5436
1155+ 1 , None , 3 , "Rect" , [0.5 , 1.0 ], seed = _RANDOM_SEED_FOR_TESTING
11541156 )
11551157 self .assertTrue (len (results ) == 6 ) # 6 lNo samples
11561158 i = 1
0 commit comments