diff --git a/optuna_dashboard/preferential/_study.py b/optuna_dashboard/preferential/_study.py index 57ab8e9f..8895d604 100644 --- a/optuna_dashboard/preferential/_study.py +++ b/optuna_dashboard/preferential/_study.py @@ -276,7 +276,9 @@ class PreferentialStudy: to generate a new trial if this method returns :obj:`True`, and to wait for human evaluation if this method returns :obj:`False`. """ - return len(get_active_trials(self._study._study_id, self._study._storage)) < self.n_generate + return ( + len(get_active_trials(self._study._study_id, self._study._storage)) < self.n_generate + ) def get_active_trials(study_id: int, storage: optuna.storages.BaseStorage) -> list[FrozenTrial]: diff --git a/python_tests/test_api.py b/python_tests/test_api.py index ae50e29a..fc67e12e 100644 --- a/python_tests/test_api.py +++ b/python_tests/test_api.py @@ -108,6 +108,8 @@ class APITestCase(TestCase): study.mark_comparison_ready(trial) study.report_preference(study.trials[0], study.trials[1]) + assert len(study.best_trials) == 1 + app = create_app(storage) study_id = study._study._study_id status, _, body = send_request( @@ -119,9 +121,8 @@ class APITestCase(TestCase): self.assertEqual(status, 200) best_trials = json.loads(body)["best_trials"] - assert len(best_trials) == 2 + assert len(best_trials) == 1 assert best_trials[0]["number"] == 0 - assert best_trials[1]["number"] == 2 def test_report_preference(self) -> None: storage = optuna.storages.InMemoryStorage()