From d18562f62c836308107a0bb3e8ba25b6277c9d48 Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Wed, 6 Dec 2023 07:02:17 +0100 Subject: [PATCH 1/2] [bug] Fix an error caused by infinity in trial.values --- optuna_dashboard/ts/components/GraphRank.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/optuna_dashboard/ts/components/GraphRank.tsx b/optuna_dashboard/ts/components/GraphRank.tsx index 7164b99b..cefe3145 100644 --- a/optuna_dashboard/ts/components/GraphRank.tsx +++ b/optuna_dashboard/ts/components/GraphRank.tsx @@ -152,13 +152,17 @@ const getRankPlotInfo = ( const zValues: number[] = [] const isFeasible: boolean[] = [] const hovertext: string[] = [] + const convertTrialValueToNumber = (value: TrialValueNumber): number => { + // TrialValueNumber takes `number`, "inf", or "-inf". + return typeof(value) === "number" ? value : value.includes("-") ? -Infinity : Infinity + }; filteredTrials.forEach((trial, i) => { const xValue = xAxis.values[i] const yValue = yAxis.values[i] if (xValue && yValue && trial.values) { xValues.push(xValue) yValues.push(yValue) - const zValue = Number(trial.values[objectiveId]) + const zValue = convertTrialValueToNumber(trial.values[objectiveId]) zValues.push(zValue) const feasibility = trial.constraints.every((c) => c <= 0) isFeasible.push(feasibility) From bdd27590a97a69216942d0d6e25b569fe5d3ba13 Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Wed, 6 Dec 2023 07:12:07 +0100 Subject: [PATCH 2/2] Apply formatter --- optuna_dashboard/ts/components/GraphRank.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/optuna_dashboard/ts/components/GraphRank.tsx b/optuna_dashboard/ts/components/GraphRank.tsx index cefe3145..6daaf10a 100644 --- a/optuna_dashboard/ts/components/GraphRank.tsx +++ b/optuna_dashboard/ts/components/GraphRank.tsx @@ -154,8 +154,12 @@ const getRankPlotInfo = ( const hovertext: string[] = [] const convertTrialValueToNumber = (value: TrialValueNumber): number => { // TrialValueNumber takes `number`, "inf", or "-inf". - return typeof(value) === "number" ? value : value.includes("-") ? -Infinity : Infinity - }; + return typeof value === "number" + ? value + : value.includes("-") + ? -Infinity + : Infinity + } filteredTrials.forEach((trial, i) => { const xValue = xAxis.values[i] const yValue = yAxis.values[i]