Skip to content

Commit

Permalink
refactor: readability
Browse files Browse the repository at this point in the history
  • Loading branch information
loiccoyle committed Aug 15, 2024
1 parent 18e866f commit 70c6a74
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/pather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,17 @@ impl Pather {
);
let top_candidates = &candidates[0..self.config.beam_width];

if self.early_stop(
&mut early_stop_count,
top_candidates
.iter()
.min_by(|(loss1, _, _), (loss2, _, _)| {
loss1
.partial_cmp(loss2)
.unwrap_or(std::cmp::Ordering::Equal)
})
.unwrap()
.0,
) {
let min_loss = top_candidates
.iter()
.min_by(|(loss1, _, _), (loss2, _, _)| {
loss1
.partial_cmp(loss2)
.unwrap_or(std::cmp::Ordering::Equal)
})
.unwrap()
.0;

if self.early_stop(&mut early_stop_count, min_loss) {
info!("Early stopping at iteration {iter_i}");
break 'iter;
}
Expand Down

0 comments on commit 70c6a74

Please sign in to comment.