Add includePruned as optional

This commit is contained in:
keisuke-umezawa
2024-08-20 23:48:46 +09:00
parent 947c5bb762
commit 6498a55f01
2 changed files with 24 additions and 5 deletions
@@ -8,13 +8,14 @@ export const GraphHistory: FC<{
studies: StudyDetail[]
logScale: boolean
includePruned: boolean
}> = ({ studies, logScale }) => {
}> = ({ studies, logScale, includePruned }) => {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
return (
<PlotHistory
studies={studies}
logScale={logScale}
includePruned={includePruned}
colorTheme={colorTheme}
/>
)
+22 -4
View File
@@ -37,10 +37,9 @@ interface HistoryPlotInfo {
export const PlotHistory: FC<{
studies: Optuna.Study[]
logScale?: boolean
includePruned?: boolean
colorTheme?: Partial<Plotly.Template>
}> = ({ studies, logScale, colorTheme }) => {
const filterPrunedTrial = false
}> = ({ studies, logScale, includePruned, colorTheme }) => {
const { graphComponentState, notifyGraphDidRender } = useGraphComponentState()
const theme = useTheme()
@@ -52,6 +51,8 @@ export const PlotHistory: FC<{
>("number")
const [logScaleInternal, setLogScaleInternal] = useState<boolean>(false)
const [includePrunedInternal, setIncludePrunedInternal] =
useState<boolean>(true)
const [markerSize, setMarkerSize] = useState<number>(5)
@@ -61,7 +62,7 @@ export const PlotHistory: FC<{
const trials = useFilteredTrialsFromStudies(
studies,
[selected],
filterPrunedTrial
includePruned === undefined ? !includePrunedInternal : !includePruned
)
const historyPlotInfos = studies.map((study, index) => {
@@ -82,6 +83,10 @@ export const PlotHistory: FC<{
setLogScaleInternal(!logScaleInternal)
}
const handleIncludePrunedChange = () => {
setIncludePrunedInternal(!includePrunedInternal)
}
const handleXAxisChange = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.value === "number") {
setXAxis("number")
@@ -189,6 +194,19 @@ export const PlotHistory: FC<{
/>
</FormControl>
) : null}
{includePruned === undefined ? (
<FormControl
component="fieldset"
sx={{ marginBottom: theme.spacing(2) }}
>
<FormLabel component="legend"> Include PRUNED trials:</FormLabel>
<Switch
checked={includePrunedInternal}
onChange={handleIncludePrunedChange}
value="enable"
/>
</FormControl>
) : null}
<FormControl>
<FormLabel component="legend">Marker size:</FormLabel>
<Slider