//! Helpers shared across the integration suites. //! //! Each integration file is its own binary, so `mod common;` compiles a copy //! per suite. Anything unused in a given suite would warn, hence the //! `#![allow(dead_code)]`. #![allow(dead_code)] use trueskill_tt::Gaussian; /// A posterior must be finite with a strictly positive sigma. /// /// A non-finite posterior is the failure mode this crate is most prone to — /// EP breaking down produces NaN rather than an error — and a zero or negative /// sigma means the precision went non-positive, which `Gaussian::sigma` reports /// as improper rather than trapping. pub fn assert_finite(g: Gaussian, what: &str) { assert!( g.mu().is_finite(), "{what}: mu is not finite (mu={}, sigma={})", g.mu(), g.sigma() ); assert!( g.sigma().is_finite() && g.sigma() > 0.0, "{what}: sigma must be finite and positive (mu={}, sigma={})", g.mu(), g.sigma() ); } /// Every point on every learning curve must be finite. pub fn assert_curve_finite(curve: &[(i64, Gaussian)], who: &str) { for (time, g) in curve { assert_finite(*g, &format!("{who} at t={time}")); } }