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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Error enums.

use std::fmt::Debug;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ResidualBlockBuildingError {
    #[error("No cost function set for residual block")]
    MissingCost,
    #[error("No parameters set for residual block")]
    MissingParameters,
    #[error(transparent)]
    ParameterBlockStorageError(#[from] ParameterBlockStorageError),
}

#[derive(Debug, Error)]
pub enum ParameterBlockStorageError {
    #[error("Index of ParameterBlock out of bounds: {index} >= {len}")]
    IndexOutOfBounds { index: usize, len: usize },
}

#[derive(Debug, Error)]
pub enum SolverOptionsBuildingError {
    #[error("SolverOptions is invalid: {0}")]
    Invalid(String),
}

/// Error for [crate::curve_fit::CurveFitProblem1DBuilder].
#[derive(Debug, Error)]
pub enum CurveFitProblemBuildError {
    #[error("Data arrays x, y, or inverse_error have different lengths")]
    DataSizesDontMatch,
    #[error("Cost function is missed")]
    FuncMissed,
    #[error("Independent parameter x is missed")]
    XMissed,
    #[error("Dependent parameter y is missed")]
    YMissed,
    #[error("Initial parameters' guess are missed")]
    ParametersMissed,
    #[error("Lower boundary size doesn't match the number of parameters")]
    LowerBoundarySizeMismatch,
    #[error("Upper boundary size doesn't match the number of parameters")]
    UpperBoundarySizeMismatch,
    #[error("Constant parameter index is out of bounds: {0}")]
    ParameterBlockStorageError(#[from] ParameterBlockStorageError),
}

/// Error for [crate::nlls_problem::NllsProblem].
#[derive(Debug, Error)]
pub enum NllsProblemError {
    #[error("No residual blocks added to the problem")]
    NoResidualBlocks,
}