Remove Display impl, better to use Debug

This commit is contained in:
2022-06-13 11:35:08 +02:00
parent 87a64acb83
commit de4b324651
3 changed files with 4 additions and 36 deletions

View File

@@ -4,4 +4,5 @@ Rust port of [TrueSkillThroughTime.py](https://github.com/glandfried/TrueSkillTh
## Todo ## Todo
- [ ] Change `time` to always be a u64 (or usize)? - [ ] Add examples (use same TrueSkillThroughTime.py)
- [ ] Change `time` to always be a u64 (or usize?)

View File

@@ -1,4 +1,3 @@
use std::fmt;
use std::ops; use std::ops;
use crate::{utils, MU, SIGMA}; use crate::{utils, MU, SIGMA};
@@ -38,26 +37,12 @@ impl Gaussian {
((self.mu() - m.mu()).abs(), (self.sigma() - m.sigma()).abs()) ((self.mu() - m.mu()).abs(), (self.sigma() - m.sigma()).abs())
} }
pub fn exclude(&self, m: Gaussian) -> Gaussian { pub fn exclude(&self, m: Gaussian) -> Self {
Gaussian::new( Self::new(
self.mu() - m.mu(), self.mu() - m.mu(),
(self.sigma().powi(2) - m.sigma().powi(2)).sqrt(), (self.sigma().powi(2) - m.sigma().powi(2)).sqrt(),
) )
} }
/*
def forget(self,gamma,t):
return Gaussian(self.mu, math.sqrt(self.sigma**2 + t*gamma**2))
def delta(self, M):
return abs(self.mu - M.mu) , abs(self.sigma - M.sigma)
def exclude(self, M):
return Gaussian(self.mu - M.mu, math.sqrt(self.sigma**2 - M.sigma**2) )
def isapprox(self, M, tol=1e-4):
return (abs(self.mu - M.mu) < tol) and (abs(self.sigma - M.sigma) < tol)
*/
} }
impl Default for Gaussian { impl Default for Gaussian {
@@ -69,12 +54,6 @@ impl Default for Gaussian {
} }
} }
impl fmt::Display for Gaussian {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "N(mu={:.3}, sigma={:.3})", self.mu, self.sigma)
}
}
impl ops::Add<Gaussian> for Gaussian { impl ops::Add<Gaussian> for Gaussian {
type Output = Gaussian; type Output = Gaussian;

View File

@@ -1,5 +1,3 @@
use std::fmt;
use crate::{Gaussian, BETA, GAMMA, N_INF}; use crate::{Gaussian, BETA, GAMMA, N_INF};
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
@@ -35,13 +33,3 @@ impl Default for Player {
Player::new(Gaussian::default(), BETA, GAMMA, N_INF) Player::new(Gaussian::default(), BETA, GAMMA, N_INF)
} }
} }
impl fmt::Display for Player {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Player({}, beta={:.3}, gamma={:.3})",
self.prior, self.beta, self.gamma
)
}
}