fix test and update

This commit is contained in:
yoshinobc
2022-04-24 17:15:49 +09:00
parent c8f7cf5de0
commit 71591c0a05
2 changed files with 12 additions and 4 deletions
@@ -72,7 +72,7 @@ class _CachedExtraStudyProperty:
if trial.state not in states_of_interest:
continue
if len(trial.intermediate_values) > 0:
if not self.has_intermediate_values and len(trial.intermediate_values) > 0:
self.has_intermediate_values = True
current = set([(n, d) for n, d in trial.distributions.items()])
@@ -1,3 +1,5 @@
from typing import Dict
from typing import List
from unittest import TestCase
import warnings
@@ -10,7 +12,7 @@ from optuna.trial import TrialState
from optuna_dashboard._cached_extra_study_property import _CachedExtraStudyProperty
class _CachedExtraStudyPropertyTestCase(TestCase):
class _CachedExtraStudyPropertySearchSpaceTestCase(TestCase):
def setUp(self) -> None:
optuna.logging.set_verbosity(optuna.logging.ERROR)
warnings.simplefilter("ignore", category=ExperimentalWarning)
@@ -115,8 +117,14 @@ class _CachedExtraStudyPropertyTestCase(TestCase):
self.assertEqual(len(cached_extra_study_property.intersection), 0)
self.assertEqual(len(cached_extra_study_property.union), 3)
class _CachedExtraStudyPropertyIntermediateTestCase(TestCase):
def setUp(self) -> None:
optuna.logging.set_verbosity(optuna.logging.ERROR)
warnings.simplefilter("ignore", category=ExperimentalWarning)
def test_no_intermediate_value(self) -> None:
intermediate_values = [
intermediate_values: List[Dict] = [
{},
{},
]
@@ -171,7 +179,7 @@ class _CachedExtraStudyPropertyTestCase(TestCase):
self.assertTrue(cached_extra_study_property.has_intermediate_values)
def test_no_trials(self) -> None:
trials = []
trials: list = []
cached_extra_study_property = _CachedExtraStudyProperty()
cached_extra_study_property.update(trials)
self.assertFalse(cached_extra_study_property.has_intermediate_values)