Merge pull request #70 from optuna/support-pruned-trials-without-report

Fix a bug to crash when trials are pruned with no intermediate values
This commit is contained in:
Masashi Shibata
2021-04-07 13:25:49 +09:00
committed by GitHub
5 changed files with 12 additions and 5 deletions
@@ -187,7 +187,9 @@ const plotHistory = (
}
let filteredTrials = study.trials.filter(
(t) => t.state === "Complete" || t.state === "Pruned"
(t) =>
t.state === "Complete" ||
(t.state === "Pruned" && t.values && t.values.length > 0)
)
if (filterCompleteTrial) {
filteredTrials = filteredTrials.filter((t) => t.state !== "Complete")
@@ -31,7 +31,9 @@ const plotIntermediateValue = (trials: Trial[]) => {
}
const filteredTrials = trials.filter(
(t) => t.state === "Complete" || t.state === "Pruned"
(t) =>
t.state === "Complete" ||
(t.state === "Pruned" && t.values && t.values.length > 0)
)
const plotData: Partial<plotly.PlotData>[] = filteredTrials.map((trial) => {
return {
@@ -32,7 +32,9 @@ const plotCoordinate = (trials: Trial[], objectiveId: number) => {
}
const filteredTrials = trials.filter(
(t) => t.state === "Complete" || t.state === "Pruned"
(t) =>
t.state === "Complete" ||
(t.state === "Pruned" && t.values && t.values.length > 0)
)
// Intersection param names
@@ -103,7 +103,7 @@ const plotParetoFront = (
},
}
const trials: Trial[] = study !== null ? study.trials : []
const trials: Trial[] = study ? study.trials : []
const completedTrials = trials.filter((t) => t.state === "Complete")
if (completedTrials.length === 0) {
@@ -140,7 +140,8 @@ const plotSlice = (
const filteredTrials = trials.filter(
(t) =>
(t.state === "Complete" || t.state === "Pruned") &&
(t.state === "Complete" ||
(t.state === "Pruned" && t.values && t.values.length > 0)) &&
t.params.find((p) => p.name == selected) !== undefined
)