Merge pull request #808 from porink0424/fix/TrialValueNumber

Drop inf & -inf from TrialValueNumber
This commit is contained in:
c-bata
2024-02-29 16:10:26 +09:00
committed by GitHub
6 changed files with 16 additions and 23 deletions
@@ -178,8 +178,8 @@ const filterFunc = (trial: Trial, objectiveId: number): boolean => {
}
return (
trial.values.length > objectiveId &&
trial.values[objectiveId] !== "inf" &&
trial.values[objectiveId] !== "-inf"
trial.values[objectiveId] !== Infinity &&
trial.values[objectiveId] !== -Infinity
)
}
@@ -244,7 +244,7 @@ const plotHistory = (
return null
}
const value = trial.values[objectiveId]
if (value === "inf" || value === "-inf") {
if (value === Infinity || value === -Infinity) {
return null
}
return value
@@ -80,8 +80,8 @@ const filterFunc = (trial: Trial, objectiveId: number): boolean => {
}
return (
trial.values.length > objectiveId &&
trial.values[objectiveId] !== "inf" &&
trial.values[objectiveId] !== "-inf"
trial.values[objectiveId] !== Infinity &&
trial.values[objectiveId] !== -Infinity
)
}
@@ -80,7 +80,10 @@ const plotIntermediateValue = (
)
const plotData: Partial<plotly.PlotData>[] = filteredTrials.map((trial) => {
const values = trial.intermediate_values.filter(
(iv) => iv.value !== "inf" && iv.value !== "-inf" && iv.value !== "nan"
(iv) =>
iv.value !== Infinity &&
iv.value !== -Infinity &&
!Number.isNaN(iv.value)
)
return {
x: values.map((iv) => iv.step),
@@ -37,11 +37,6 @@ export const TrialTable: FC<{
} else if (secondVal === undefined) {
return ascending ? 1 : -1
}
if (firstVal === "-inf" || secondVal === "inf") {
return 1
} else if (secondVal === "-inf" || firstVal === "inf") {
return -1
}
return firstVal < secondVal ? 1 : -1
},
toCellValue: (i) => {
@@ -69,11 +64,6 @@ export const TrialTable: FC<{
} else if (secondVal === undefined) {
return ascending ? 1 : -1
}
if (firstVal === "-inf" || secondVal === "inf") {
return 1
} else if (secondVal === "-inf" || firstVal === "inf") {
return -1
}
return firstVal < secondVal ? 1 : -1
},
toCellValue: (i) => {
+5 -5
View File
@@ -218,9 +218,9 @@ const getTrialValues = (
callback: (vals: any[]) => {
values.push(
vals[1] === "INF_NEG"
? "-inf"
? -Infinity
: vals[1] === "INF_POS"
? "+inf"
? Infinity
: vals[0]
)
},
@@ -389,11 +389,11 @@ const getTrialIntermediateValues = (
step: vals[0],
value:
vals[2] === "INF_NEG"
? "-inf"
? -Infinity
: vals[2] === "INF_POS"
? "+inf"
? Infinity
: vals[2] === "NAN"
? "nan"
? NaN
: vals[1],
})
},
+2 -2
View File
@@ -1,7 +1,7 @@
declare const IS_VSCODE: boolean
type TrialValueNumber = number | "inf" | "-inf"
type TrialIntermediateValueNumber = number | "inf" | "-inf" | "nan"
type TrialValueNumber = number
type TrialIntermediateValueNumber = number
type TrialState = "Running" | "Complete" | "Pruned" | "Fail" | "Waiting"
type TrialStateFinished = "Complete" | "Fail" | "Pruned"
type StudyDirection = "maximize" | "minimize" | "not_set"