Skip to main content

oxicuda_seq/
error.rs

1//! Error types for `oxicuda-seq`.
2
3use thiserror::Error;
4
5/// Errors that can be produced by sequence model algorithms.
6#[derive(Debug, Error)]
7pub enum SeqError {
8    #[error("shape mismatch: expected {expected}, got {got}")]
9    ShapeMismatch { expected: usize, got: usize },
10
11    #[error("dimension mismatch between operands: a={a}, b={b}")]
12    DimensionMismatch { a: usize, b: usize },
13
14    #[error("algorithm did not converge after {iter} iterations")]
15    NotConverged { iter: usize },
16
17    #[error("invalid configuration: {0}")]
18    InvalidConfiguration(String),
19
20    #[error("empty input")]
21    EmptyInput,
22
23    #[error("index {index} out of bounds (len = {len})")]
24    IndexOutOfBounds { index: usize, len: usize },
25
26    #[error("numerical instability detected: {0}")]
27    NumericalInstability(String),
28
29    #[error("probability {0} is out of [0, 1]")]
30    ProbabilityOutOfRange(f64),
31
32    #[error("invalid parameter `{name}`: value = {value}")]
33    InvalidParameter { name: String, value: f64 },
34
35    #[error("unsupported SM version: {0}")]
36    UnsupportedSmVersion(u32),
37
38    #[error("invalid observation: {0}")]
39    InvalidObservation(String),
40
41    #[error("length mismatch: a={a}, b={b}")]
42    LengthMismatch { a: usize, b: usize },
43
44    #[error("graph invariant violated: {0}")]
45    GraphInvariantViolated(String),
46}
47
48/// Result alias for fallible sequence operations.
49pub type SeqResult<T> = Result<T, SeqError>;