From a76c8e67aab0fe91e14aedbd281adb4531e39ef2 Mon Sep 17 00:00:00 2001 From: Goose Date: Mon, 3 Nov 2025 10:06:48 +1000 Subject: [PATCH 1/2] fix(fmt): apply 2024 formatting to KDE --- src/function/kernel.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/function/kernel.rs b/src/function/kernel.rs index 4046a831..7fbc7dae 100644 --- a/src/function/kernel.rs +++ b/src/function/kernel.rs @@ -66,11 +66,7 @@ pub struct Epanechnikov; impl Kernel for Epanechnikov { fn evaluate(&self, x: f64) -> f64 { let a = x.abs(); - if a <= 1.0 { - 0.75 * (1.0 - a * a) - } else { - 0.0 - } + if a <= 1.0 { 0.75 * (1.0 - a * a) } else { 0.0 } } fn support(&self) -> Option<(f64, f64)> { @@ -85,11 +81,7 @@ pub struct Triangular; impl Kernel for Triangular { fn evaluate(&self, x: f64) -> f64 { let a = x.abs(); - if a <= 1.0 { - 1.0 - a - } else { - 0.0 - } + if a <= 1.0 { 1.0 - a } else { 0.0 } } fn support(&self) -> Option<(f64, f64)> { @@ -143,11 +135,7 @@ pub struct Uniform; impl Kernel for Uniform { fn evaluate(&self, x: f64) -> f64 { - if x.abs() <= 1.0 { - 0.5 - } else { - 0.0 - } + if x.abs() <= 1.0 { 0.5 } else { 0.0 } } fn support(&self) -> Option<(f64, f64)> { From c80f1b1d380e3ce01b564f815b7ebc5d00e04729 Mon Sep 17 00:00:00 2001 From: Goose Date: Mon, 3 Nov 2025 10:28:52 +1000 Subject: [PATCH 2/2] fix: use core instead of std in KDE --- src/function/kernel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/function/kernel.rs b/src/function/kernel.rs index 7fbc7dae..daf9b3d0 100644 --- a/src/function/kernel.rs +++ b/src/function/kernel.rs @@ -28,7 +28,7 @@ //! assert!((e.evaluate(0.0) - 0.75).abs() < 1e-12); //! ``` -use std::f64::consts::{FRAC_PI_2, PI}; +use core::f64::consts::{FRAC_PI_2, PI}; /// Common interface for kernel functions used in KDE and smoothing. pub trait Kernel {