Skip to main content

rsl_interpolation/
error.rs

1#[derive(thiserror::Error, Debug)]
2/// The error type for Interpolator creation and data checking.
3pub enum InterpolationError {
4    /// x points dataset is not sorted.
5    #[error("x values must be strictly increasing.")]
6    UnsortedDataset,
7
8    /// x and y datasets have different length.
9    #[error("Supplied datasets must be 1D and of equal length.")]
10    DatasetMismatch,
11
12    /// Supplied array size is less than the interpolation type's minimum size.
13    #[error("Supplied array size is less than the interpolation type's minimum size.")]
14    NotEnoughPoints,
15
16    /// Supplied z-grid dataset must be 1D with length of `xsize*ysize`.
17    #[error("Supplied z-grid dataset must be 1D with length of `xsize*ysize`.")]
18    ZGridMismatch,
19
20    /// BLAS error solving Tridiagonal linear system.
21    #[error("BLAS error solving Tridiagonal matrix of {which_interp} Interpolator: {source}")]
22    BLASTridiagError {
23        which_interp: String,
24        #[source]
25        source: ndarray_linalg::error::LinalgError,
26    },
27
28    /// Supplied value is outside the range of the supplied xdata.
29    #[error("{0}")]
30    Domain1dError(#[from] Domain1dError),
31
32    /// Supplied value is outside the range of the supplied xdata or ydata.
33    #[error("{0}")]
34    Domain2dError(#[from] Domain2dError),
35}
36
37/// Returned when the supplied value is outside the range of the supplied xdata.
38#[derive(thiserror::Error, Debug)]
39#[error("1D Interpolation domain error: x = {x}")]
40pub struct Domain1dError {
41    pub x: f64,
42}
43
44/// Returned  when the supplied value is outside the range of the supplied xdata or ydata.
45#[derive(thiserror::Error, Debug)]
46#[error("1D Interpolation domain error: x = {x}, y = {y}")]
47pub struct Domain2dError {
48    pub x: f64,
49    pub y: f64,
50}