@@ -71,8 +71,8 @@ def load_pickle(filename: str):
7171
7272
7373def get_experiment_filename (PREFIX ) -> str :
74- """Returns the name of the experiment.
75- This is the PREFIX with the suffix ".pkl".
74+ """Returns the name of the experiment file .
75+ This is the PREFIX with the suffix "_exp .pkl".
7676 It is none, if PREFIX is None.
7777
7878 Args:
@@ -91,7 +91,32 @@ def get_experiment_filename(PREFIX) -> str:
9191 if PREFIX is None :
9292 return None
9393 else :
94- filename = PREFIX + ".pkl"
94+ filename = PREFIX + "_exp.pkl"
95+ return filename
96+
97+
98+ def get_result_filename (PREFIX ) -> str :
99+ """Returns the name of the result file.
100+ This is the PREFIX with the suffix "_res.pkl".
101+ It is none, if PREFIX is None.
102+
103+ Args:
104+ PREFIX (str): Prefix of the experiment.
105+
106+ Returns:
107+ filename (str): Name of the experiment.
108+
109+ Examples:
110+ >>> from spotpython.utils.file import get_experiment_name
111+ >>> from spotpython.utils.init import fun_control_init
112+ >>> fun_control = fun_control_init(PREFIX="branin")
113+ >>> PREFIX = fun_control["PREFIX"]
114+ >>> filename = get_experiment_filename(PREFIX)
115+ """
116+ if PREFIX is None :
117+ return None
118+ else :
119+ filename = PREFIX + "_res.pkl"
95120 return filename
96121
97122
@@ -115,8 +140,8 @@ def load_result(PREFIX) -> tuple:
115140 """
116141 if PREFIX is None :
117142 raise ValueError ("No PREFIX provided." )
118- PKL_NAME = PREFIX + "_res.pkl"
119- spot_tuner , fun_control , design_control , surrogate_control , optimizer_control = load_experiment (PKL_NAME = PKL_NAME )
143+ filename = get_result_filename ( PREFIX )
144+ spot_tuner , fun_control , design_control , surrogate_control , optimizer_control = load_experiment (PKL_NAME = filename )
120145 return spot_tuner , fun_control , design_control , surrogate_control , optimizer_control
121146
122147
0 commit comments