- some clippy fixes

This commit is contained in:
w.pomp
2026-07-31 15:32:41 +02:00
parent db2b72c3bf
commit f75f12db16
3 changed files with 19 additions and 23 deletions
+1 -1
View File
@@ -442,7 +442,7 @@ where
self.metric.replace(IntMut {
mu: mu.to_vec(),
metric: metric,
metric,
derivative: dmetric.clone(),
});
// self.metric.replace(IntMut {
+14 -14
View File
@@ -379,6 +379,20 @@ mod tests {
#[test]
fn test_lbfgs_quadratic_with_minimum() {
struct QuadraticWithMinimum;
impl ObjectiveFunction<f64> for QuadraticWithMinimum {
fn evaluate(&self, point: &[f64]) -> f64 {
let x = point[0];
(x - 2.0).powi(2)
}
fn gradient(&self, point: &[f64]) -> Option<Vec<f64>> {
let x = point[0];
Some(vec![2.0 * (x - 2.0)])
}
}
let f = QuadraticWithMinimum;
let initial_point = vec![0.0];
let config = OptimizationConfig {
@@ -412,17 +426,3 @@ mod tests {
}
}
}
struct QuadraticWithMinimum;
impl ObjectiveFunction<f64> for QuadraticWithMinimum {
fn evaluate(&self, point: &[f64]) -> f64 {
let x = point[0];
(x - 2.0).powi(2)
}
fn gradient(&self, point: &[f64]) -> Option<Vec<f64>> {
let x = point[0];
Some(vec![2.0 * (x - 2.0)])
}
}
+4 -8
View File
@@ -10,18 +10,15 @@ use std::marker::PhantomData;
/// Optimizer type for registration
#[derive(Clone, Debug, PartialEq)]
#[derive(Default)]
pub enum Optimizer {
/// L-BFGS optimizer (fast, requires consistent gradients)
#[default]
LBFGS,
/// Adaptive Stochastic Gradient Descent (robust, handles noisy gradients)
ASGD,
}
impl Default for Optimizer {
fn default() -> Self {
Self::LBFGS
}
}
#[derive(Clone, Debug)]
pub struct RegistrationStep {
@@ -358,12 +355,11 @@ impl<D: Dimension> Registration<D> {
&scales,
);
if let Some(result) = optimization_result {
if result.optimal_point.iter().all(|i| i.is_finite()) {
if let Some(result) = optimization_result
&& result.optimal_point.iter().all(|i| i.is_finite()) {
p = self.fixed_mu.combine(&result.optimal_point);
}
}
}
Ok(Transform::<D>::new(p, fixed.shape().to_vec()))
}