From 747098b6894b88a2445cf03aaf34bc4b2e009f27 Mon Sep 17 00:00:00 2001 From: porink0424 Date: Fri, 21 Jun 2024 18:37:28 +0900 Subject: [PATCH] Add the test to check the study with dynamic search space --- tslib/storage/test/generate_assets.py | 4 ++-- tslib/storage/test/journal.test.mjs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tslib/storage/test/generate_assets.py b/tslib/storage/test/generate_assets.py index 2e79e141..7799b726 100644 --- a/tslib/storage/test/generate_assets.py +++ b/tslib/storage/test/generate_assets.py @@ -44,9 +44,9 @@ def create_optuna_storage(storage: BaseStorage) -> None: def objective_single_dynamic(trial: optuna.Trial) -> float: category = trial.suggest_categorical("category", ["foo", "bar"]) if category == "foo": - return (trial.suggest_float("x1", 0, 10) - 2) ** 2 + return (trial.suggest_float("x", 0, 10) - 2) ** 2 else: - return -((trial.suggest_float("x2", -10, 0) + 5) ** 2) + return -((trial.suggest_float("x", -10, 0) + 5) ** 2) study.optimize(objective_single_dynamic, n_trials=50) diff --git a/tslib/storage/test/journal.test.mjs b/tslib/storage/test/journal.test.mjs index 1f8f1299..70e4f7a5 100644 --- a/tslib/storage/test/journal.test.mjs +++ b/tslib/storage/test/journal.test.mjs @@ -16,6 +16,18 @@ describe("Test Journal File Storage", async () => { studySummaries.map((_summary, index) => storage.getStudy(index)) ) + it("Check the study with dynamic search space", () => { + const study = studies.find((s) => s.name === "single-objective-dynamic") + assert.deepStrictEqual( + study.union_search_space.map((item) => item.name).sort(), + ["x", "x", "category"].sort() + ) + assert.deepStrictEqual( + study.intersection_search_space.map((item) => item.name).sort(), + ["category"].sort() + ) + }) + it("Check the study including Infinities", () => { const study = studies.find((s) => s.name === "single-inf") study.trials.forEach((trial, index) => {