diff --git a/hack/visual_regression_test.py b/hack/visual_regression_test.py index 77a795c3..e3b54cbc 100644 --- a/hack/visual_regression_test.py +++ b/hack/visual_regression_test.py @@ -168,6 +168,29 @@ 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: + 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") + trial.suggest_categorical("cbow", [True]) + trial.suggest_categorical("model", ["m1"]) + + 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) 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) }