From 2360f2c3a09b28ae6924f9afca3d7a6ea3a283cc Mon Sep 17 00:00:00 2001 From: c-bata Date: Wed, 15 Mar 2023 11:38:27 +0900 Subject: [PATCH 1/3] Update visual regression tests for issue 410 --- hack/visual_regression_test.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hack/visual_regression_test.py b/hack/visual_regression_test.py index 77a795c3..03e19b4f 100644 --- a/hack/visual_regression_test.py +++ b/hack/visual_regression_test.py @@ -168,6 +168,30 @@ def create_dummy_storage() -> optuna.storages.InMemoryStorage: study.optimize(objective_single_inf_report, n_trials=50) + # Issue 410 + study = optuna.create_study(study_name="Issue 410", storage=storage, sampler=sampler) + + def objective_issue_410(trial: optuna.Trial) -> float: + resample_rate = trial.suggest_categorical("resample_rate", ["50ms"]) + channels = trial.suggest_categorical("channels", ["all"]) + window_size = trial.suggest_categorical("window_size", [256]) + if trial.number > 15: + raise Exception("Unexpected error") + cbow = trial.suggest_categorical("cbow", [True]) + model_type = trial.suggest_categorical("model", ["m1"]) + height = None + + trial.set_user_attr("epochs", 0) + trial.set_user_attr("deterministic", True) + if trial.number > 10: + raise Exception("unexpeccted error") + trial.set_user_attr("folder", "/path/to/folder") + trial.set_user_attr("resample_type", "foo") + trial.set_user_attr("run_id", "0001") + return 1.0 + + study.optimize(objective_issue_410, n_trials=20, catch=(Exception,)) + # No trials single-objective study optuna.create_study(study_name="single-no-trials", storage=storage, sampler=sampler) From 1089d5513f7f022683e26e1eb53840dd0cba9eee Mon Sep 17 00:00:00 2001 From: c-bata Date: Thu, 25 May 2023 18:47:52 +0900 Subject: [PATCH 2/3] Fix bug of issue #410 --- .../ts/components/GraphContour.tsx | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/optuna_dashboard/ts/components/GraphContour.tsx b/optuna_dashboard/ts/components/GraphContour.tsx index 0590540d..fa207cce 100644 --- a/optuna_dashboard/ts/components/GraphContour.tsx +++ b/optuna_dashboard/ts/components/GraphContour.tsx @@ -166,6 +166,31 @@ const plotContour = ( const xIndices = xAxis.indices const yIndices = yAxis.indices + const layout: Partial = { + xaxis: { + title: xParam.name, + type: xAxis.isCat ? "category" : undefined, + }, + yaxis: { + title: yParam.name, + type: yAxis.isCat ? "category" : undefined, + }, + margin: { + l: 50, + t: 0, + r: 50, + b: 50, + }, + uirevision: "true", + template: mode === "dark" ? plotlyDarkTemplate : {}, + } + + // TODO(c-bata): Support parameters that only have the single value + if (xIndices.length <= 1 || yIndices.length <= 1) { + plotly.react(plotDomId, [], layout) + return + } + const xValues: plotly.Datum[] = [] const yValues: plotly.Datum[] = [] const zValues: plotly.Datum[][] = new Array(yIndices.length) @@ -214,25 +239,6 @@ const plotContour = ( showlegend: false, }, ] - - const layout: Partial = { - xaxis: { - title: xParam.name, - type: xAxis.isCat ? "category" : undefined, - }, - yaxis: { - title: yParam.name, - type: yAxis.isCat ? "category" : undefined, - }, - margin: { - l: 50, - t: 0, - r: 50, - b: 50, - }, - uirevision: "true", - template: mode === "dark" ? plotlyDarkTemplate : {}, - } plotly.react(plotDomId, plotData, layout) } From 8c52163d3cde8a980625b3113754d7e8f298d28b Mon Sep 17 00:00:00 2001 From: c-bata Date: Thu, 25 May 2023 18:51:45 +0900 Subject: [PATCH 3/3] Fix flake8 error --- hack/visual_regression_test.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hack/visual_regression_test.py b/hack/visual_regression_test.py index 03e19b4f..e3b54cbc 100644 --- a/hack/visual_regression_test.py +++ b/hack/visual_regression_test.py @@ -172,14 +172,13 @@ def create_dummy_storage() -> optuna.storages.InMemoryStorage: study = optuna.create_study(study_name="Issue 410", storage=storage, sampler=sampler) def objective_issue_410(trial: optuna.Trial) -> float: - resample_rate = trial.suggest_categorical("resample_rate", ["50ms"]) - channels = trial.suggest_categorical("channels", ["all"]) - window_size = trial.suggest_categorical("window_size", [256]) + trial.suggest_categorical("resample_rate", ["50ms"]) + trial.suggest_categorical("channels", ["all"]) + trial.suggest_categorical("window_size", [256]) if trial.number > 15: raise Exception("Unexpected error") - cbow = trial.suggest_categorical("cbow", [True]) - model_type = trial.suggest_categorical("model", ["m1"]) - height = None + trial.suggest_categorical("cbow", [True]) + trial.suggest_categorical("model", ["m1"]) trial.set_user_attr("epochs", 0) trial.set_user_attr("deterministic", True)