From 61f8a9ccce8ea90821a4da69000f42bbf8687ced Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Wed, 24 Oct 2018 11:13:06 +0200 Subject: [PATCH] Fmt. --- src/factor_graph.rs | 27 +++++++++++++++++++++------ src/lib.rs | 6 +++--- src/math.rs | 3 +-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/factor_graph.rs b/src/factor_graph.rs index 1d4cc1b..4934b1d 100644 --- a/src/factor_graph.rs +++ b/src/factor_graph.rs @@ -58,7 +58,7 @@ impl Variable { self.value = value; } - pub fn get_value(&self) -> Gaussian { + pub fn get_value(&self) -> Gaussian { self.value } @@ -101,7 +101,10 @@ impl PriorFactor { } pub fn start(&self, variable_arena: &mut VariableArena) { - variable_arena.get_mut(self.variable).unwrap().update_value(self.id, self.gaussian); + variable_arena + .get_mut(self.variable) + .unwrap() + .update_value(self.id, self.gaussian); } } @@ -146,7 +149,10 @@ impl LikelihoodFactor { let gaussian = Gaussian::from_pi_tau(a * (x.pi() - fx.pi()), a * (x.tau() - fx.tau())); - variable_arena.get_mut(self.mean).unwrap().update_message(self.id, gaussian); + variable_arena + .get_mut(self.mean) + .unwrap() + .update_message(self.id, gaussian); } pub fn update_value(&self, variable_arena: &mut VariableArena) { @@ -164,7 +170,10 @@ impl LikelihoodFactor { let gaussian = Gaussian::from_pi_tau(a * (y.pi() - fy.pi()), a * (y.tau() - fy.tau())); - variable_arena.get_mut(self.value).unwrap().update_message(self.id, gaussian); + variable_arena + .get_mut(self.value) + .unwrap() + .update_message(self.id, gaussian); } } @@ -224,7 +233,10 @@ impl SumFactor { let gaussian = Gaussian::from_pi_tau(new_pi, new_tau); - variable_arena.get_mut(variable).unwrap().update_message(self.id, gaussian); + variable_arena + .get_mut(variable) + .unwrap() + .update_message(self.id, gaussian); } pub fn update_sum(&self, variable_arena: &mut VariableArena) { @@ -372,6 +384,9 @@ impl TruncateFactor { let gaussian = Gaussian::from_pi_tau(c / m_w, (d + sqrt_c * v) / m_w); - variable_arena.get_mut(self.variable).unwrap().update_value(self.id, gaussian); + variable_arena + .get_mut(self.variable) + .unwrap() + .update_value(self.id, gaussian); } } diff --git a/src/lib.rs b/src/lib.rs index ee02d74..b8c47c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ -extern crate statrs; extern crate noisy_float; +extern crate statrs; mod factor_graph; mod gaussian; @@ -28,7 +28,6 @@ const DRAW_PROBABILITY: f64 = 0.10; /// A basis to check reliability of the result. const DELTA: f64 = 0.0001; - fn draw_margin(p: f64, beta: f64, total_players: f64) -> f64 { math::icdf((p + 1.0) / 2.0) * total_players.sqrt() * beta } @@ -78,7 +77,8 @@ pub fn rate(rating_groups: &[&[Gaussian]]) { for (i, rating) in flatten_ratings.iter().enumerate() { let variable = ss[i]; - let gaussian = Gaussian::from_mu_sigma(rating.mu(), (rating.sigma().powi(2) + tau_sqr).sqrt()); + let gaussian = + Gaussian::from_mu_sigma(rating.mu(), (rating.sigma().powi(2) + tau_sqr).sqrt()); skill.push(PriorFactor::new( &mut variable_arena, diff --git a/src/math.rs b/src/math.rs index 598297e..284cd83 100644 --- a/src/math.rs +++ b/src/math.rs @@ -1,4 +1,4 @@ -use statrs::distribution::{Normal, Univariate, Continuous}; +use statrs::distribution::{Continuous, Normal, Univariate}; const S2PI: f64 = 2.50662827463100050242E0; @@ -137,7 +137,6 @@ pub fn icdf(x: f64) -> f64 { ndtri(x) } - #[cfg(test)] mod tests { use super::*;