Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
About:
- drop some unnecessary mut
- Option.is_some() instead of != none
  • Loading branch information
alphaville committed Sep 26, 2023
1 parent a83981f commit e6968eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/alm/alm_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ mod tests {
"exists right away"
);

let mut alm_optimizer = alm_optimizer
let alm_optimizer = alm_optimizer
.with_initial_inner_tolerance(1e-3)
.with_epsilon_tolerance(1e-3);
assert!(!alm_optimizer.is_exit_criterion_satisfied());
Expand All @@ -1433,7 +1433,7 @@ mod tests {
let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem);
let mut alm_cache = AlmCache::new(panoc_cache, n1, n2);
let alm_problem = make_dummy_alm_problem(n1, n2);
let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
.with_sufficient_decrease_coefficient(0.1);

// should stall because iteration = 0
Expand All @@ -1458,7 +1458,7 @@ mod tests {
let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem);
let mut alm_cache = AlmCache::new(panoc_cache, n1, n2);
let alm_problem = make_dummy_alm_problem(n1, n2);
let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
.with_sufficient_decrease_coefficient(0.1);

// should stall because iteration = 0
Expand All @@ -1483,7 +1483,7 @@ mod tests {
let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem);
let mut alm_cache = AlmCache::new(panoc_cache, n1, n2);
let alm_problem = make_dummy_alm_problem(n1, n2);
let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem)
.with_sufficient_decrease_coefficient(0.1);

// should stall because iteration = 0
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a> Rectangle<'a> {
/// dimensions
///
pub fn new(xmin: Option<&'a [f64]>, xmax: Option<&'a [f64]>) -> Self {
assert!(xmin != None || xmax != None); // xmin or xmax must be Some
assert!(xmin.is_some() || xmax.is_some()); // xmin or xmax must be Some
assert!(
xmin.is_none() || xmax.is_none() || xmin.unwrap().len() == xmax.unwrap().len(),
"incompatible dimensions of xmin and xmax"
Expand Down
2 changes: 1 addition & 1 deletion src/core/fbs/fbs_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
///
/// The method panics if the specified tolerance is not positive
pub fn with_tolerance(
mut self,
self,
tolerance: f64,
) -> FBSOptimizer<'a, GradientType, ConstraintType, CostType> {
assert!(tolerance > 0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/core/panoc/panoc_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
/// ## Panics
///
/// The method panics if the specified tolerance is not positive
pub fn with_tolerance(mut self, tolerance: f64) -> Self {
pub fn with_tolerance(self, tolerance: f64) -> Self {
assert!(tolerance > 0.0, "tolerance must be larger than 0");

self.panoc_engine.cache.tolerance = tolerance;
Expand Down

0 comments on commit e6968eb

Please sign in to comment.