From 07d3c4e84692c2da637144f8a762e8c77095ad48 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:23:06 -0500 Subject: [PATCH] chore: remove abandoned module `error` --- src/error.rs | 120 --------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 src/error.rs diff --git a/src/error.rs b/src/error.rs deleted file mode 100644 index bf95334f..00000000 --- a/src/error.rs +++ /dev/null @@ -1,120 +0,0 @@ -use std::error::Error; -use std::fmt; - -/// Enumeration of possible errors thrown within the `statrs` library -#[derive(Clone, PartialEq, Debug)] -pub enum StatsError { - /// Generic bad input parameter error - BadParams, - /// An argument must be finite - ArgFinite(&'static str), - /// An argument should have been positive and was not - ArgMustBePositive(&'static str), - /// An argument should have been non-negative and was not - ArgNotNegative(&'static str), - /// An argument should have fallen between an inclusive range but didn't - ArgIntervalIncl(&'static str, f64, f64), - /// An argument should have fallen between an exclusive range but didn't - ArgIntervalExcl(&'static str, f64, f64), - /// An argument should have fallen in a range excluding the min but didn't - ArgIntervalExclMin(&'static str, f64, f64), - /// An argument should have falled in a range excluding the max but didn't - ArgIntervalExclMax(&'static str, f64, f64), - /// An argument must have been greater than a value but wasn't - ArgGt(&'static str, f64), - /// An argument must have been greater than another argument but wasn't - ArgGtArg(&'static str, &'static str), - /// An argument must have been greater than or equal to a value but wasn't - ArgGte(&'static str, f64), - /// An argument must have been greater than or equal to another argument - /// but wasn't - ArgGteArg(&'static str, &'static str), - /// An argument must have been less than a value but wasn't - ArgLt(&'static str, f64), - /// An argument must have been less than another argument but wasn't - ArgLtArg(&'static str, &'static str), - /// An argument must have been less than or equal to a value but wasn't - ArgLte(&'static str, f64), - /// An argument must have been less than or equal to another argument but - /// wasn't - ArgLteArg(&'static str, &'static str), - /// Containers of the same length were expected - ContainersMustBeSameLength, - /// Computation failed to converge, - ComputationFailedToConverge, - /// Elements in a container were expected to sum to a value but didn't - ContainerExpectedSum(&'static str, f64), - /// Elements in a container were expected to sum to a variable but didn't - ContainerExpectedSumVar(&'static str, &'static str), - /// Special case exception - SpecialCase(&'static str), -} - -impl Error for StatsError {} - -impl fmt::Display for StatsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - StatsError::BadParams => write!(f, "Bad distribution parameters"), - StatsError::ArgFinite(s) => write!(f, "Argument {s} must be finite"), - StatsError::ArgMustBePositive(s) => write!(f, "Argument {s} must be positive"), - StatsError::ArgNotNegative(s) => write!(f, "Argument {s} must be non-negative"), - StatsError::ArgIntervalIncl(s, min, max) => { - write!(f, "Argument {s} not within interval [{min}, {max}]") - } - StatsError::ArgIntervalExcl(s, min, max) => { - write!(f, "Argument {s} not within interval ({min}, {max})") - } - StatsError::ArgIntervalExclMin(s, min, max) => { - write!(f, "Argument {s} not within interval ({min}, {max}]") - } - StatsError::ArgIntervalExclMax(s, min, max) => { - write!(f, "Argument {s} not within interval [{min}, {max})") - } - StatsError::ArgGt(s, val) => write!(f, "Argument {s} must be greater than {val}"), - StatsError::ArgGtArg(s, val) => { - write!(f, "Argument {s} must be greater than {val}") - } - StatsError::ArgGte(s, val) => { - write!(f, "Argument {s} must be greater than or equal to {val}") - } - StatsError::ArgGteArg(s, val) => { - write!(f, "Argument {s} must be greater than or equal to {val}") - } - StatsError::ArgLt(s, val) => write!(f, "Argument {s} must be less than {val}"), - StatsError::ArgLtArg(s, val) => write!(f, "Argument {s} must be less than {val}"), - StatsError::ArgLte(s, val) => { - write!(f, "Argument {s} must be less than or equal to {val}") - } - StatsError::ArgLteArg(s, val) => { - write!(f, "Argument {s} must be less than or equal to {val}") - } - StatsError::ContainersMustBeSameLength => { - write!(f, "Expected containers of same length") - } - StatsError::ComputationFailedToConverge => write!(f, "Computation failed to converge"), - StatsError::ContainerExpectedSum(s, sum) => { - write!(f, "Elements in container {s} expected to sum to {sum}") - } - StatsError::ContainerExpectedSumVar(s, sum) => { - write!(f, "Elements in container {s} expected to sum to {sum}") - } - StatsError::SpecialCase(s) => write!(f, "{s}"), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn assert_sync() {} - fn assert_send() {} - - #[test] - fn test_sync_send() { - // Error types should implement Sync and Send - assert_sync::(); - assert_send::(); - } -}