diff --git a/optuna_dashboard/ts/components/GraphRank.tsx b/optuna_dashboard/ts/components/GraphRank.tsx index 7164b99b..6daaf10a 100644 --- a/optuna_dashboard/ts/components/GraphRank.tsx +++ b/optuna_dashboard/ts/components/GraphRank.tsx @@ -152,13 +152,21 @@ 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)