use ndarray_linalg::error::LinalgError;
use std::error::Error;
use std::fmt::{self, Display};
pub type Result<T> = std::result::Result<T, FastIcaError>;
#[derive(Debug)]
pub enum FastIcaError {
InvalidValue(String),
SvdDecomposition,
Linalg(LinalgError),
}
impl Display for FastIcaError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::InvalidValue(message) => write!(f, "Invalid value encountered: {}", message),
Self::SvdDecomposition => write!(
f,
"SVD Decomposition failed, X could be an Ill-Conditioned matrix",
),
Self::Linalg(error) => write!(f, "Linalg Error: {}", error),
}
}
}
impl Error for FastIcaError {}
impl From<LinalgError> for FastIcaError {
fn from(error: LinalgError) -> FastIcaError {
FastIcaError::Linalg(error)
}
}