Skip to main content

egobox_gp/
errors.rs

1use thiserror::Error;
2
3/// A result type for GP regression algorithm
4pub type Result<T> = std::result::Result<T, GpError>;
5
6/// An error when using [`GaussianProcess`](crate::GaussianProcess) or a [`SparseGaussianProcess`](crate::SparseGaussianProcess) algorithm
7#[derive(Error, Debug)]
8pub enum GpError {
9    /// When LikelihoodComputation computation fails
10    #[error("LikelihoodComputation computation error: {0}")]
11    LikelihoodComputationError(String),
12    /// When linear algebra computation fails
13    #[cfg(feature = "blas")]
14    #[error("Linalg BLAS error: {0}")]
15    LinalgBlasError(#[from] ndarray_linalg::error::LinalgError),
16    #[error(transparent)]
17    /// When linear algebra computation fails   
18    LinalgError(#[from] linfa_linalg::LinalgError),
19    /// When clustering fails
20    #[error("Empty cluster: {0}")]
21    EmptyCluster(String),
22    /// When PLS fails
23    #[error("PLS error: {0}")]
24    PlsError(#[from] linfa_pls::PlsError),
25    /// When a linfa error occurs
26    #[error(transparent)]
27    LinfaError(#[from] linfa::error::Error),
28    /// When error during saving
29    #[cfg(feature = "persistent")]
30    #[error("Save error: {0}")]
31    SaveError(#[from] serde_json::Error),
32    /// When error during loading
33    #[error("Load IO error")]
34    LoadIoError(#[from] std::io::Error),
35    /// When error during loading
36    #[error("Load error: {0}")]
37    LoadError(String),
38    /// When error dur to a bad value
39    #[error("InvalidValue error: {0}")]
40    InvalidValueError(String),
41}