use crate::k_means::KMeansError;
#[cfg(not(feature = "blas"))]
use linfa_linalg::LinalgError;
#[cfg(feature = "blas")]
use ndarray_linalg::error::LinalgError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, GmmError>;
#[derive(Error, Debug)]
pub enum GmmError {
#[error("Invalid value encountered: {0}")]
InvalidValue(String),
#[error(
"Linalg Error: \
Fitting the mixture model failed because some components have \
ill-defined empirical covariance (for instance caused by singleton \
or collapsed samples). Try to decrease the number of components, \
or increase reg_covar. Error: {0}"
)]
LinalgError(#[from] LinalgError),
#[error("Fitting failed: {0}")]
EmptyCluster(String),
#[error("Fitting failed: {0}")]
LowerBoundError(String),
#[error("Fitting failed: {0}")]
NotConverged(String),
#[error("Initial KMeans failed: {0}")]
KMeansError(#[from] KMeansError),
#[error(transparent)]
LinfaError(#[from] linfa::error::Error),
#[error(transparent)]
MinMaxError(#[from] ndarray_stats::errors::MinMaxError),
}