This commit is contained in:
Contramundum
2023-09-01 14:36:07 +09:00
parent 6553bb5fbd
commit b929bc6b36
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -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]:
+3 -2
View File
@@ -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()