Skip to content

Commit 4bbbd92

Browse files
committed
Fix storage of linesearch step if it is None
1 parent 7489852 commit 4bbbd92

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

varipeps/optimization/optimizer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ def autosave_function_restartable(
289289

290290
grp_restart_data.attrs["random_noise_retries"] = random_noise_retries
291291
grp_restart_data.attrs["count"] = count
292-
grp_restart_data.attrs["linesearch_step"] = linesearch_step
293292
grp_restart_data.attrs["projector_method"] = projector_method
294293
grp_restart_data.attrs["signal_reset_descent_dir"] = signal_reset_descent_dir
295294

295+
if linesearch_step is not None:
296+
grp_restart_data.attrs["linesearch_step"] = linesearch_step
297+
296298
if varipeps_config.optimizer_method is Optimizing_Methods.BFGS:
297299
bfgs_prefactor, bfgs_B_inv = descent_method_tuple
298300
grp_restart_data.attrs["bfgs_prefactor"] = bfgs_prefactor
@@ -1321,12 +1323,13 @@ def restart_from_state_file(filename: PathLike):
13211323
random_noise_retries = int(grp_restart_data.attrs["random_noise_retries"])
13221324
restart_state["random_noise_retries"] = random_noise_retries
13231325
restart_state["count"] = int(grp_restart_data.attrs["count"])
1324-
restart_state["linesearch_step"] = grp_restart_data.attrs["linesearch_step"]
13251326
restart_state["projector_method"] = grp_restart_data.attrs["projector_method"]
13261327
restart_state["signal_reset_descent_dir"] = grp_restart_data.attrs[
13271328
"signal_reset_descent_dir"
13281329
]
13291330

1331+
restart_state["linesearch_step"] = grp_restart_data.attrs.get("linesearch_step")
1332+
13301333
restart_state["max_trunc_error_list"] = {
13311334
k: None for k in range(random_noise_retries + 1)
13321335
}

0 commit comments

Comments
 (0)