@@ -106,6 +106,7 @@ def __init__(self,
106106 sensitivity_simulation : SensitivitySimulation ,
107107 parameters : list [SensitivityParameter ],
108108 results_path : Path ,
109+ seed : Optional [int ]= None ,
109110 ) -> None :
110111 """Create a sensitivity analysis for given parameter ids.
111112
@@ -125,6 +126,10 @@ def __init__(self,
125126 self .results_path : Path = results_path
126127 results_path .mkdir (parents = True , exist_ok = True )
127128
129+ # set seed
130+ if seed is not None :
131+ np .random .seed (seed )
132+
128133 # parameter samples for sensitivity; shape: (num_samples x num_parameters)
129134 self .samples : Optional [xr .DataArray ] = None
130135 # outputs for given samples; shape: (num_samples x num_outputs)
@@ -303,9 +308,10 @@ class LocalSensitivityAnalysis(SensitivityAnalysis):
303308 def __init__ (self , sensitivity_simulation : SensitivitySimulation ,
304309 parameters : list [SensitivityParameter ],
305310 results_path : Path ,
306- difference : float = 0.01 ):
311+ difference : float = 0.01 ,
312+ ** kwargs ) -> None :
307313
308- super ().__init__ (sensitivity_simulation , parameters , results_path )
314+ super ().__init__ (sensitivity_simulation , parameters , results_path , ** kwargs )
309315
310316 self .difference : float = difference
311317
@@ -399,11 +405,12 @@ class SobolSensitivityAnalysis(SensitivityAnalysis):
399405 def __init__ (self ,
400406 sensitivity_simulation : SensitivitySimulation ,
401407 parameters : list [SensitivityParameter ],
402- N : int ,
403408 results_path : Path ,
409+ N : int ,
410+ ** kwargs ,
404411 ):
405412
406- super ().__init__ (sensitivity_simulation , parameters , results_path )
413+ super ().__init__ (sensitivity_simulation , parameters , results_path , ** kwargs )
407414 self .N : int = N
408415
409416 # define the problem specification
@@ -532,11 +539,12 @@ class SamplingSensitivityAnalysis(SensitivityAnalysis):
532539 def __init__ (self ,
533540 sensitivity_simulation : SensitivitySimulation ,
534541 parameters : list [SensitivityParameter ],
535- N : int ,
536542 results_path : Path ,
543+ N : int ,
544+ ** kwargs ,
537545 ):
538546
539- super ().__init__ (sensitivity_simulation , parameters , results_path )
547+ super ().__init__ (sensitivity_simulation , parameters , results_path , ** kwargs )
540548 self .N : int = N
541549
542550
@@ -630,8 +638,13 @@ def df_sampling_sensitivity(
630638 # latex table
631639 latex_path = df_path .parent / f"{ df_path .stem } .tex"
632640 df_latex : pd .DataFrame = df .copy ()
633- df_latex .drop ('uid' , axis = 1 , inplace = True )
634- df_latex .to_latex (latex_path , index = False , float_format = "{:.3g}" .format )
641+ df_latex .drop (['uid' , 'N' , "min" , "max" , "q005" , "q095" ], axis = 1 , inplace = True )
642+ latex_str = df_latex .to_latex (None , index = False , float_format = "{:.3g}" .format )
643+ latex_str = latex_str .replace ("∞" , "$\infty$" )
644+ latex_str = latex_str .replace ("*" , "$\cdot$" )
645+
646+ with open (latex_path , "w" ) as f :
647+ f .write (latex_str )
635648
636649 return df
637650
0 commit comments