2018 edition, and clippy fixes.

This commit is contained in:
2019-01-02 21:58:02 +01:00
parent a2210055db
commit 8271464fe6
5 changed files with 17 additions and 19 deletions

View File

@@ -2,6 +2,7 @@
name = "trueskill"
version = "0.1.0"
authors = ["Anders Olsson <anders.e.olsson@gmail.com>"]
edition = "2018"
[dependencies]
log = "0.4"

View File

@@ -2,8 +2,10 @@ use std::collections::HashMap;
use std::f64;
use std::ops;
use gaussian::Gaussian;
use math;
use log::*;
use crate::gaussian::Gaussian;
use crate::math;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct VariableId {

View File

@@ -56,6 +56,7 @@ impl ops::Mul<Gaussian> for Gaussian {
type Output = Gaussian;
fn mul(self, rhs: Gaussian) -> Gaussian {
#[allow(clippy::suspicious_arithmetic_impl)]
Gaussian::from_pi_tau(self.pi + rhs.pi, self.tau + rhs.tau)
}
}
@@ -64,6 +65,7 @@ impl ops::Div<Gaussian> for Gaussian {
type Output = Gaussian;
fn div(self, rhs: Gaussian) -> Gaussian {
#[allow(clippy::suspicious_arithmetic_impl)]
Gaussian::from_pi_tau(self.pi - rhs.pi, self.tau - rhs.tau)
}
}

View File

@@ -1,22 +1,11 @@
#[macro_use]
extern crate log;
extern crate statrs;
#[cfg(test)]
#[macro_use]
extern crate approx;
#[cfg(test)]
extern crate env_logger;
mod factor_graph;
mod gaussian;
mod math;
mod matrix;
use factor_graph::*;
use gaussian::Gaussian;
use matrix::Matrix;
use crate::factor_graph::*;
use crate::gaussian::Gaussian;
use crate::matrix::Matrix;
/// Default initial mean of ratings.
pub const MU: f64 = 25.0;
@@ -376,7 +365,7 @@ impl Default for TrueSkill {
#[cfg(test)]
mod tests {
use approx::{AbsDiffEq, RelativeEq};
use approx::*;
use env_logger;
use super::*;

View File

@@ -1,3 +1,5 @@
#![allow(clippy::unreadable_literal, clippy::excessive_precision)]
use statrs::distribution::{Continuous, Normal, Univariate};
const S2PI: f64 = 2.50662827463100050242_e0;
@@ -99,7 +101,7 @@ fn ndtri(y0: f64) -> f64 {
};
if y > 0.13533528323661269189 {
y = y - 0.5;
y -= 0.5;
let y2 = y * y;
return (y + y * (y2 * polevl(y2, &P0, 4) / p1evl(y2, &Q0, 8))) * S2PI;
@@ -136,10 +138,12 @@ pub fn icdf(x: f64) -> f64 {
#[cfg(test)]
mod tests {
use approx::*;
use super::*;
#[test]
fn test_cdf() {
assert_eq!(cdf(0.5), 0.6914624612740131);
assert_relative_eq!(cdf(0.5), 0.6914624612740131);
}
}