From 96e2e17c1275e851118205024fb405aef178b005 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Tue, 26 Dec 2023 15:13:10 +0100 Subject: [PATCH 1/2] define ctrlc handler prior to match statement (clippy) --- argmin/src/core/executor.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/argmin/src/core/executor.rs b/argmin/src/core/executor.rs index 184f9c970..f77ee66fe 100644 --- a/argmin/src/core/executor.rs +++ b/argmin/src/core/executor.rs @@ -152,14 +152,15 @@ where let interp = interrupt.clone(); // This is currently a hack to allow checkpoints to be run again within the // same program (usually not really a use case anyway). Unfortunately, this - // means that any subsequent run started afterwards will have not Ctrl-C + // means that any subsequent run started afterwards will not have Ctrl-C // handling available... This should also be a problem in case one tries to run // two consecutive optimizations. There is ongoing work in the ctrlc crate // (channels and such) which may solve this problem. So far, we have to live // with this. - match ctrlc::set_handler(move || { + let handler = move || { interp.store(true, Ordering::SeqCst); - }) { + }; + match ctrlc::set_handler(handler) { Err(ctrlc::Error::MultipleHandlers) => Ok(()), interp => interp, }?; From a51ec64c2cf95bb4cb9511cc13db618563f093c7 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Tue, 26 Dec 2023 15:13:44 +0100 Subject: [PATCH 2/2] Define list of params passed to bulk_ methods as arrays (clippy) --- argmin/src/core/problem.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/argmin/src/core/problem.rs b/argmin/src/core/problem.rs index 763f44e39..9e1048440 100644 --- a/argmin/src/core/problem.rs +++ b/argmin/src/core/problem.rs @@ -605,7 +605,7 @@ impl Problem { /// # assert_eq!(res[0], vec![1.0f64, 1.0f64]); /// # assert_eq!(res[1], vec![1.0f64, 1.0f64]); /// ``` - pub fn bulk_apply

(&mut self, params: &Vec

) -> Result, Error> + pub fn bulk_apply

(&mut self, params: &[P]) -> Result, Error> where P: std::borrow::Borrow + SyncAlias, O::Output: SendAlias, @@ -686,7 +686,7 @@ impl Problem { /// # assert_eq!(res[0], 4.0f64); /// # assert_eq!(res[1], 4.0f64); /// ``` - pub fn bulk_cost

(&mut self, params: &Vec

) -> Result, Error> + pub fn bulk_cost

(&mut self, params: &[P]) -> Result, Error> where P: std::borrow::Borrow + SyncAlias, O::Output: SendAlias, @@ -767,7 +767,7 @@ impl Problem { /// # assert_eq!(res[0], vec![1.0f64, 1.0f64]); /// # assert_eq!(res[1], vec![1.0f64, 1.0f64]); /// ``` - pub fn bulk_gradient

(&mut self, params: &Vec

) -> Result, Error> + pub fn bulk_gradient

(&mut self, params: &[P]) -> Result, Error> where P: std::borrow::Borrow + SyncAlias, O::Gradient: SendAlias, @@ -847,7 +847,7 @@ impl Problem { /// # assert_eq!(res[0], vec![vec![1.0f64, 0.0f64], vec![0.0f64, 1.0f64]]); /// # assert_eq!(res[1], vec![vec![1.0f64, 0.0f64], vec![0.0f64, 1.0f64]]); /// ``` - pub fn bulk_hessian

(&mut self, params: &Vec

) -> Result, Error> + pub fn bulk_hessian

(&mut self, params: &[P]) -> Result, Error> where P: std::borrow::Borrow + SyncAlias, O::Hessian: SendAlias, @@ -926,7 +926,7 @@ impl Problem { /// # assert_eq!(res[0], vec![vec![1.0f64, 0.0f64], vec![0.0f64, 1.0f64]]); /// # assert_eq!(res[1], vec![vec![1.0f64, 0.0f64], vec![0.0f64, 1.0f64]]); /// ``` - pub fn bulk_jacobian

(&mut self, params: &Vec

) -> Result, Error> + pub fn bulk_jacobian

(&mut self, params: &[P]) -> Result, Error> where P: std::borrow::Borrow + SyncAlias, O::Jacobian: SendAlias,