Skip to content

Commit bc76bef

Browse files
committed
fix: make Optimizer.best_loss return infinity with no trial
1 parent 7ee6449 commit bc76bef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pyannote/pipeline/optimizer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Optimizer:
7676
Seed value for the random number generator of the sampler.
7777
Defaults to no seed.
7878
average_case : `bool`, optional
79-
Optimize for average case (default).
79+
Optimize for average case (default).
8080
Set to False to optimize for worst case.
8181
"""
8282

@@ -148,7 +148,12 @@ def __init__(
148148
@property
149149
def best_loss(self) -> float:
150150
"""Return best loss so far"""
151-
return self.study_.best_value
151+
try:
152+
best_value = self.study_.best_value
153+
except Exception:
154+
direction: int = 1 if self.pipeline.get_direction() == "minimize" else -1
155+
best_value = direction * np.inf
156+
return best_value
152157

153158
@property
154159
def best_params(self) -> dict:

0 commit comments

Comments
 (0)