use crate::traits::neighborhood::CellId;
use core::fmt;
use deep_causality_algebra::RealField;
#[derive(Debug, Clone, PartialEq)]
pub enum LightConeViolation<R: RealField> {
AllSpacelike,
CellSignature {
cell_id: CellId,
eigenvalues: Vec<R>,
},
}
impl<R: RealField + fmt::Debug> fmt::Display for LightConeViolation<R> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::AllSpacelike => write!(
f,
"Lorentzian signature requires at least one timelike axis; \
all-false `timelike_axes` pattern is degenerate."
),
Self::CellSignature {
cell_id,
eigenvalues,
} => write!(
f,
"Light-cone violation at cell {cell_id:?}: local metric tensor \
has eigenvalues {eigenvalues:?}; expected exactly one negative \
eigenvalue (Lorentzian signature)."
),
}
}
}
impl<R: RealField + fmt::Debug> std::error::Error for LightConeViolation<R> {}