Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy lints (ctrlc handler and slices instead of vecs) #380

Merged
merged 2 commits into from
Dec 26, 2023
Merged
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
7 changes: 4 additions & 3 deletions argmin/src/core/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}?;
Expand Down
10 changes: 5 additions & 5 deletions argmin/src/core/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl<O: Operator> Problem<O> {
/// # assert_eq!(res[0], vec![1.0f64, 1.0f64]);
/// # assert_eq!(res[1], vec![1.0f64, 1.0f64]);
/// ```
pub fn bulk_apply<P>(&mut self, params: &Vec<P>) -> Result<Vec<O::Output>, Error>
pub fn bulk_apply<P>(&mut self, params: &[P]) -> Result<Vec<O::Output>, Error>
where
P: std::borrow::Borrow<O::Param> + SyncAlias,
O::Output: SendAlias,
Expand Down Expand Up @@ -686,7 +686,7 @@ impl<O: CostFunction> Problem<O> {
/// # assert_eq!(res[0], 4.0f64);
/// # assert_eq!(res[1], 4.0f64);
/// ```
pub fn bulk_cost<P>(&mut self, params: &Vec<P>) -> Result<Vec<O::Output>, Error>
pub fn bulk_cost<P>(&mut self, params: &[P]) -> Result<Vec<O::Output>, Error>
where
P: std::borrow::Borrow<O::Param> + SyncAlias,
O::Output: SendAlias,
Expand Down Expand Up @@ -767,7 +767,7 @@ impl<O: Gradient> Problem<O> {
/// # assert_eq!(res[0], vec![1.0f64, 1.0f64]);
/// # assert_eq!(res[1], vec![1.0f64, 1.0f64]);
/// ```
pub fn bulk_gradient<P>(&mut self, params: &Vec<P>) -> Result<Vec<O::Gradient>, Error>
pub fn bulk_gradient<P>(&mut self, params: &[P]) -> Result<Vec<O::Gradient>, Error>
where
P: std::borrow::Borrow<O::Param> + SyncAlias,
O::Gradient: SendAlias,
Expand Down Expand Up @@ -847,7 +847,7 @@ impl<O: Hessian> Problem<O> {
/// # 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<P>(&mut self, params: &Vec<P>) -> Result<Vec<O::Hessian>, Error>
pub fn bulk_hessian<P>(&mut self, params: &[P]) -> Result<Vec<O::Hessian>, Error>
where
P: std::borrow::Borrow<O::Param> + SyncAlias,
O::Hessian: SendAlias,
Expand Down Expand Up @@ -926,7 +926,7 @@ impl<O: Jacobian> Problem<O> {
/// # 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<P>(&mut self, params: &Vec<P>) -> Result<Vec<O::Jacobian>, Error>
pub fn bulk_jacobian<P>(&mut self, params: &[P]) -> Result<Vec<O::Jacobian>, Error>
where
P: std::borrow::Borrow<O::Param> + SyncAlias,
O::Jacobian: SendAlias,
Expand Down
Loading