use crate::{Error, Result, canonical_zero};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RipsOptions {
max_dimension: usize,
max_edge: Option<f64>,
}
impl RipsOptions {
pub fn new(max_dimension: usize, max_edge: Option<f64>) -> Result<Self> {
if max_dimension > 1 {
return Err(Error::UnsupportedDimension {
requested: max_dimension,
max_supported: 1,
});
}
if let Some(value) = max_edge {
if !value.is_finite() {
return Err(Error::NonFiniteValue {
field: "max_edge",
index: None,
});
}
if value < 0.0 {
return Err(Error::NegativeValue {
field: "max_edge",
index: None,
});
}
}
Ok(Self {
max_dimension,
max_edge: max_edge.map(canonical_zero),
})
}
pub fn max_dimension(&self) -> usize {
self.max_dimension
}
pub fn max_edge(&self) -> Option<f64> {
self.max_edge
}
}
impl Default for RipsOptions {
fn default() -> Self {
Self {
max_dimension: 1,
max_edge: None,
}
}
}