linfa_pls/
errors.rs

1#[cfg(not(feature = "blas"))]
2use linfa_linalg::LinalgError;
3#[cfg(feature = "blas")]
4use ndarray_linalg::error::LinalgError;
5use thiserror::Error;
6pub type Result<T> = std::result::Result<T, PlsError>;
7
8#[derive(Error, Debug)]
9pub enum PlsError {
10    #[error("Number of samples should be greater than 1, got {0}")]
11    NotEnoughSamplesError(usize),
12    #[error("Number of components should be in [1, {upperbound}], got {actual}")]
13    BadComponentNumberError { upperbound: usize, actual: usize },
14    #[error("The tolerance is should not be negative, NaN or inf but is {0}")]
15    InvalidTolerance(f32),
16    #[error("The maximal number of iterations should be positive")]
17    ZeroMaxIter,
18    #[error("Singular vector computation power method: max iterations ({0}) reached")]
19    PowerMethodNotConvergedError(usize),
20    #[error("Constant residual detected in power method")]
21    PowerMethodConstantResidualError(),
22    #[error(transparent)]
23    LinalgError(#[from] LinalgError),
24    #[error(transparent)]
25    LinfaError(#[from] linfa::error::Error),
26    #[error(transparent)]
27    MinMaxError(#[from] ndarray_stats::errors::MinMaxError),
28}