Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/algorithms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,8 @@ pub trait Algorithms<E: Equation + Send + 'static>: Sync + Send + 'static {
/// until the algorithm converges or meets a stopping criteria.
fn fit(&mut self) -> Result<NPResult<E>> {
self.initialize().unwrap();
loop {
match self.next_cycle()? {
Status::Continue => continue,
Status::Stop(_) => break,
}
}
Ok(self.into_npresult()?)
while let Status::Continue = self.next_cycle()? {}
self.into_npresult()
}

#[allow(clippy::wrong_self_convention)]
Expand Down
7 changes: 1 addition & 6 deletions src/bestdose/posterior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,7 @@ pub fn npagfull_refinement(

// Run NPAG optimization
let refinement_result = npag.initialize().and_then(|_| {
loop {
match npag.next_cycle()? {
Status::Continue => continue,
Status::Stop(_) => break,
}
}
while let Status::Continue = npag.next_cycle()? {}
Ok(())
});

Expand Down
5 changes: 5 additions & 0 deletions src/structs/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ impl Weights {
self.weights.nrows()
}

/// Check if there are no weights.
pub fn is_empty(&self) -> bool {
self.weights.nrows() == 0
}

/// Get a vector representation of the weights.
pub fn to_vec(&self) -> Vec<f64> {
self.weights.iter().cloned().collect()
Expand Down