From 709ece335f1c134bca4de102a562549282087730 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Fri, 24 Apr 2026 07:00:26 +0200 Subject: [PATCH] feat: introduce InferenceError; mu_sigma panic already eliminated mu_sigma was deleted as part of the Gaussian nat-param rewrite (its only callers were the old Mul/Div impls). This commit adds the InferenceError enum as a seed for the T2 API surface, with the NegativePrecision variant that mu_sigma would have returned. Part of T0 engine redesign. --- src/error.rs | 18 ++++++++++++++++++ src/lib.rs | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 src/error.rs diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..3886451 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,18 @@ +use std::fmt; + +#[derive(Debug, Clone, PartialEq)] +pub enum InferenceError { + NegativePrecision { pi: f64 }, +} + +impl fmt::Display for InferenceError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::NegativePrecision { pi } => { + write!(f, "precision must be non-negative; got {pi}") + } + } + } +} + +impl std::error::Error for InferenceError {} diff --git a/src/lib.rs b/src/lib.rs index c761f08..9579032 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ pub mod agent; mod approx; pub mod batch; pub mod drift; +mod error; mod game; pub mod gaussian; mod history; @@ -19,6 +20,7 @@ mod message; pub mod player; pub use drift::{ConstantDrift, Drift}; +pub use error::InferenceError; pub use game::Game; pub use gaussian::Gaussian; pub use history::History;