#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SpotEstimator {
#[default]
Best,
Mom,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SpotInitialThreshold {
#[default]
P2,
Empirical,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SpotExcessUpdate {
#[default]
GreaterOrEqual,
Greater,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SpotConfig {
pub q: f64,
pub low_tail: bool,
pub discard_anomalies: bool,
pub level: f64,
pub max_excess: usize,
}
impl Default for SpotConfig {
fn default() -> Self {
Self {
q: 0.0001,
low_tail: false,
discard_anomalies: true,
level: 0.998,
max_excess: 200,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use approx::assert_relative_eq;
#[test]
fn test_spot_config_default() {
let config = SpotConfig::default();
assert_relative_eq!(config.q, 0.0001);
assert!(!config.low_tail);
assert!(config.discard_anomalies);
assert_relative_eq!(config.level, 0.998);
assert_eq!(config.max_excess, 200);
}
#[test]
fn test_spot_config_clone() {
let config1 = SpotConfig::default();
let config2 = config1.clone();
assert_relative_eq!(config1.q, config2.q);
assert_eq!(config1.low_tail, config2.low_tail);
assert_eq!(config1.discard_anomalies, config2.discard_anomalies);
assert_relative_eq!(config1.level, config2.level);
assert_eq!(config1.max_excess, config2.max_excess);
}
#[test]
fn test_spot_estimator_default_keeps_existing_behavior() {
assert_eq!(SpotEstimator::default(), SpotEstimator::Best);
}
#[test]
fn test_spot_initial_threshold_default_keeps_existing_behavior() {
assert_eq!(SpotInitialThreshold::default(), SpotInitialThreshold::P2);
}
#[test]
fn test_spot_excess_update_default_keeps_existing_behavior() {
assert_eq!(
SpotExcessUpdate::default(),
SpotExcessUpdate::GreaterOrEqual
);
}
}