mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Add serializers tests for is_preferential attr
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
import optuna
|
||||
from optuna_dashboard._serializer import serialize_attrs
|
||||
from optuna_dashboard._serializer import serialize_study_detail
|
||||
from optuna_dashboard.preferential import create_study
|
||||
|
||||
from optuna_dashboard._storage import get_study_summaries
|
||||
|
||||
|
||||
def test_serialize_bytes() -> None:
|
||||
@@ -17,3 +20,25 @@ def test_serialize_dict() -> None:
|
||||
}
|
||||
)
|
||||
assert len(serialized) <= 1
|
||||
|
||||
|
||||
def test_get_study_detail_is_preferential() -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(storage=storage)
|
||||
study_summaries = get_study_summaries(storage)
|
||||
assert len(study_summaries) == 1
|
||||
|
||||
study_summary = study_summaries[0]
|
||||
study_detail = serialize_study_detail(study_summary, [], study.trials, [], [], [], False)
|
||||
assert study_detail["is_preferential"]
|
||||
|
||||
|
||||
def test_get_study_detail_is_not_preferential() -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = optuna.create_study(storage=storage)
|
||||
study_summaries = get_study_summaries(storage)
|
||||
assert len(study_summaries) == 1
|
||||
|
||||
study_summary = study_summaries[0]
|
||||
study_detail = serialize_study_detail(study_summary, [], study.trials, [], [], [], False)
|
||||
assert not study_detail["is_preferential"]
|
||||
|
||||
Reference in New Issue
Block a user