From 1cd18c16f915422b5342811cb86ff7d10bb2fb16 Mon Sep 17 00:00:00 2001 From: Manuel Raimann Date: Thu, 12 Feb 2026 17:57:29 +0100 Subject: [PATCH] fix: address review findings in grid sampler, parallel optimization, and CSV export - Rename stale "GridSearchSampler" panic message to "GridSampler" - Assert concurrency > 0 in optimize_parallel to prevent deadlock - Fix inaccurate comment in CSV export (empty for all non-complete trials, not just pruned) --- src/sampler/grid.rs | 4 ++-- src/study/async_impl.rs | 2 ++ src/study/export.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sampler/grid.rs b/src/sampler/grid.rs index b991f35..f6aea7b 100644 --- a/src/sampler/grid.rs +++ b/src/sampler/grid.rs @@ -601,7 +601,7 @@ impl Sampler for GridSampler { // Check if all points have been exhausted assert!( cached.current_index < cached.points.len(), - "GridSearchSampler: all grid points exhausted" + "GridSampler: all grid points exhausted" ); // Get the current grid point and advance the index @@ -908,7 +908,7 @@ mod tests { } #[test] - #[should_panic(expected = "GridSearchSampler: all grid points exhausted")] + #[should_panic(expected = "GridSampler: all grid points exhausted")] fn test_sampler_panics_after_exhaustion() { let sampler = GridSampler::new(); let dist = Distribution::Categorical(CategoricalDistribution { n_choices: 2 }); diff --git a/src/study/async_impl.rs b/src/study/async_impl.rs index ca9e0a5..2d0a1a6 100644 --- a/src/study/async_impl.rs +++ b/src/study/async_impl.rs @@ -171,6 +171,8 @@ where use tokio::sync::Semaphore; use tokio::task::JoinSet; + assert!(concurrency > 0, "concurrency must be at least 1"); + #[cfg(feature = "tracing")] let _span = tracing::info_span!("optimize_parallel", n_trials, concurrency, direction = ?self.direction).entered(); diff --git a/src/study/export.rs b/src/study/export.rs index beff14b..4933982 100644 --- a/src/study/export.rs +++ b/src/study/export.rs @@ -91,7 +91,7 @@ where for trial in trials.iter() { write!(writer, "{}", trial.id)?; - // Value: empty for pruned trials. + // Value: empty for non-complete trials. if trial.state == TrialState::Complete { write!(writer, ",{}", trial.value)?; } else {