1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! An error when modeling a Linear algorithm
use linfa::Float;
use thiserror::Error;

pub type Result<T, F> = std::result::Result<T, LinearError<F>>;

/// An error when modeling a Linear algorithm
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum LinearError<F: Float> {
    /// Errors encountered when using argmin's solver
    #[error("argmin {0}")]
    Argmin(#[from] argmin::core::Error),
    #[error(transparent)]
    BaseCrate(#[from] linfa::Error),
    #[error("At least one sample needed")]
    NotEnoughSamples,
    #[error("At least one target needed")]
    NotEnoughTargets,
    #[error("penalty should be positive, but is {0}")]
    InvalidPenalty(F),
    #[error("tweedie distribution power should not be in (0, 1), but is {0}")]
    InvalidTweediePower(F),
    #[error("some value(s) of y are out of the valid range for power value {0}")]
    InvalidTargetRange(F),
    #[error(transparent)]
    #[cfg(feature = "blas")]
    LinalgBlasError(#[from] ndarray_linalg::error::LinalgError),
    #[error(transparent)]
    LinalgError(#[from] linfa_linalg::LinalgError),
}