fix: correct total trial count when adding additional trials (#385)
Some checks are pending
CI / Check and build (Python 3.10) (push) Waiting to run
CI / Check and build (Python 3.11) (push) Waiting to run
CI / Check and build (Python 3.12) (push) Waiting to run
CI / Check and build (Python 3.13) (push) Waiting to run

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 <noreply@anthropic.com>
This commit is contained in:
Petre 2026-06-17 11:28:40 +02:00 committed by GitHub
parent b186d6c28e
commit 554a58aa0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)