Skip to content

Commit a3ce98f

Browse files
committed
Merge branch 'release/3.1.1'
2 parents 082f5c1 + cfde42e commit a3ce98f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

doc/source/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Changelog
33
#########
44

5+
Version 3.1.1 (2025-02-07)
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+
- fix: should_prune() takes no argument
9+
- fix: make `Optimizer.best_loss`` return infinity with no trial
10+
11+
512
Version 3.1.0 (2025-01-12)
613
~~~~~~~~~~~~~~~~~~~~~~~~~~
714

pyannote/pipeline/optimizer.py

Lines changed: 9 additions & 4 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:
@@ -255,8 +260,8 @@ def objective(trial: Trial) -> float:
255260
continue
256261

257262
trial.report(np.mean(losses) if metric is None else abs(metric), i)
258-
if trial.should_prune(i):
259-
raise optuna.structs.TrialPruned()
263+
if trial.should_prune():
264+
raise optuna.TrialPruned()
260265

261266
if show_progress != False:
262267
progress_bar.close()

0 commit comments

Comments
 (0)