From 554a58aa0f732ebcbac36ee774d5b47eac341714 Mon Sep 17 00:00:00 2001 From: Petre <90782432+kali113@users.noreply.github.com> Date: Wed, 17 Jun 2026 11:28:40 +0200 Subject: [PATCH] fix: correct total trial count when adding additional trials (#385) When a study is cancelled mid-way and the user selects 'Run additional trials', settings.n_trials was incremented by n_additional_trials, accumulating the original total into the new count. E.g. cancelling 200 trials at 30 and adding 10 gave n_trials=210 instead of 40, causing 'Running trial 31 of 210...' and planning 180 more trials instead of 10. Fix by recalculating n_trials from actual completed trials + additional, so the total reflects the new intended target, not the old one. Fixes #379 Co-authored-by: Claude --- src/heretic/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heretic/main.py b/src/heretic/main.py index c232ada..36c1e49 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -802,7 +802,7 @@ def run(): if n_additional_trials == 0: continue - settings.n_trials += n_additional_trials + settings.n_trials = len(study.trials) + n_additional_trials study.set_user_attr("settings", settings.model_dump_json()) study.set_user_attr("finished", False)