From 797a8cdce5c1541e25f8ec96a913432444fdf123 Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Thu, 28 Dec 2023 07:37:39 +0100 Subject: [PATCH] Add missing value filter --- optuna_dashboard/ts/components/DataGrid.tsx | 2 +- optuna_dashboard/ts/components/TrialTable.tsx | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/optuna_dashboard/ts/components/DataGrid.tsx b/optuna_dashboard/ts/components/DataGrid.tsx index 9763d103..93c95eb2 100644 --- a/optuna_dashboard/ts/components/DataGrid.tsx +++ b/optuna_dashboard/ts/components/DataGrid.tsx @@ -282,7 +282,7 @@ function DataGridHeaderColumn(props: { )} - {choice} + {choice ?? "(missing value)"} ))} diff --git a/optuna_dashboard/ts/components/TrialTable.tsx b/optuna_dashboard/ts/components/TrialTable.tsx index daf39439..bd26921b 100644 --- a/optuna_dashboard/ts/components/TrialTable.tsx +++ b/optuna_dashboard/ts/components/TrialTable.tsx @@ -87,20 +87,26 @@ export const TrialTable: FC<{ })) columns.push(...objectiveColumns) } + const isDynamicSpace = + studyDetail?.union_search_space.length !== + studyDetail?.intersection_search_space.length studyDetail?.union_search_space.forEach((s) => { const sortable = s.distribution.type !== "CategoricalDistribution" const filterChoices = s.distribution.type === "CategoricalDistribution" ? s.distribution.choices.map((c) => c.value) : undefined + const filterChoicesWithNull: (string | null)[] | undefined = filterChoices + ? [...filterChoices, null] + : undefined columns.push({ field: "params", label: `Param ${s.name}`, toCellValue: (i) => - trials[i].params.find((p) => p.name === s.name) - ?.param_external_value || null, + trials[i].params.find((p) => p.name === s.name)?.param_external_value || + null, sortable: sortable, - filterChoices: filterChoices, + filterChoices: isDynamicSpace ? filterChoicesWithNull : filterChoices, // eslint-disable-next-line @typescript-eslint/no-unused-vars less: (firstEl, secondEl, _): number => { const firstVal = firstEl.params.find(