use crate::config::*;
#[cfg_attr(feature = "python-bindings", pyclass(frozen))]
#[derive(Clone, Debug, PartialEq)]
pub enum Overlap {
Percentage {
pct: Flt,
},
Number {
N: usize,
},
NoOverlap {},
}
impl Default for Overlap {
fn default() -> Self {
Overlap::Percentage { pct: 50. }
}
}
#[cfg(feature = "python-bindings")]
#[cfg_attr(feature = "python-bindings", pymethods)]
impl Overlap {
#[inline]
fn __eq__(&self, other: &Self) -> bool {
self == other
}
fn __str__(&self) -> String {
self.name()
}
#[staticmethod]
#[pyo3(name = "default")]
fn default_py() -> Self {
Self::default()
}
#[staticmethod]
fn some_settings() -> Vec<Overlap> {
use Overlap::*;
vec![
NoOverlap {},
Percentage { pct: 25. },
Percentage { pct: 50. },
Percentage { pct: 90. },
]
}
}
impl Overlap {
pub fn name(&self) -> String {
use Overlap::*;
match &self {
NoOverlap {} => "No overlap".into(),
Percentage { pct } => format! {"{pct} %"},
Number { N } => format! {"{N} samples"},
}
}
}
#[cfg(test)]
mod test {
use crate::ps::overlap::Overlap;
#[test]
fn test_overlap1() {
assert_eq!(Overlap::NoOverlap {}.name(), "No overlap");
}
}