mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Merge pull request #366 from c-bata/slice-union-user-attrs
Support user attributes on GraphSlice
This commit is contained in:
@@ -88,7 +88,10 @@ class _CachedExtraStudyProperty:
|
||||
|
||||
def _update_user_attrs(self, trial: FrozenTrial) -> None:
|
||||
# TODO(c-bata): Support numpy-specific number types.
|
||||
current_user_attrs = {k: isinstance(v, (int, float)) for k, v in trial.user_attrs.items()}
|
||||
current_user_attrs = {
|
||||
k: not isinstance(v, bool) and isinstance(v, (int, float))
|
||||
for k, v in trial.user_attrs.items()
|
||||
}
|
||||
for attr_name, current_is_sortable in current_user_attrs.items():
|
||||
is_sortable = self._union_user_attrs.get(attr_name)
|
||||
if is_sortable is None:
|
||||
|
||||
@@ -16,7 +16,7 @@ import { plotlyDarkTemplate } from "./PlotlyDarkMode"
|
||||
import {
|
||||
Target,
|
||||
useFilteredTrials,
|
||||
useObjectiveTargets,
|
||||
useObjectiveAndUserAttrTargets,
|
||||
useParamTargets,
|
||||
} from "../trialFilter"
|
||||
import { useMergedUnionSearchSpace } from "../searchSpace"
|
||||
@@ -36,7 +36,7 @@ export const GraphSlice: FC<{
|
||||
const theme = useTheme()
|
||||
|
||||
const [objectiveTargets, selectedObjective, setObjectiveTarget] =
|
||||
useObjectiveTargets(study)
|
||||
useObjectiveAndUserAttrTargets(study)
|
||||
const searchSpace = useMergedUnionSearchSpace(study?.union_search_space)
|
||||
const [paramTargets, selectedParamTarget, setParamTarget] =
|
||||
useParamTargets(searchSpace)
|
||||
@@ -96,7 +96,7 @@ export const GraphSlice: FC<{
|
||||
>
|
||||
Slice
|
||||
</Typography>
|
||||
{study !== null && study.directions.length !== 1 && (
|
||||
{objectiveTargets.length !== 1 && (
|
||||
<FormControl component="fieldset">
|
||||
<FormLabel component="legend">Objective:</FormLabel>
|
||||
<Select
|
||||
|
||||
@@ -254,11 +254,11 @@ class _CachedExtraStudyPropertyUserAttrs(TestCase):
|
||||
|
||||
def test_infer_sortable(self) -> None:
|
||||
user_attrs_list: list[dict[str, Any]] = [
|
||||
{"a": 1, "b": 1, "c": 1, "d": "a", "e": 1},
|
||||
{"a": 1, "b": 1, "c": 1, "d": "a", "e": 1, "f": True},
|
||||
{"a": 2, "b": "a", "c": "a", "d": "a"},
|
||||
{"a": 3, "b": None, "c": 3, "d": "a", "e": 3},
|
||||
]
|
||||
expected = {"a": True, "b": False, "c": False, "d": False, "e": True}
|
||||
expected = {"a": True, "b": False, "c": False, "d": False, "e": True, "f": False}
|
||||
|
||||
trials = []
|
||||
for user_attrs in user_attrs_list:
|
||||
|
||||
Reference in New Issue
Block a user