fastcit_core/error.rs
1//! Error type for the conditional-independence core.
2
3use thiserror::Error;
4
5/// Errors that can arise when constructing a [`crate::dataset::Dataset`] or
6/// running a conditional-independence test.
7#[derive(Debug, Error)]
8pub enum CIError {
9 /// Columns (or X/Y/Z vectors) did not share a common length.
10 #[error("dimension mismatch: {0}")]
11 DimensionMismatch(String),
12
13 /// The data is degenerate for the requested test (e.g. a column with zero
14 /// variance for a correlation test, or too few rows).
15 #[error("degenerate data: {0}")]
16 DegenerateData(String),
17
18 /// A numerical routine failed (e.g. distribution construction or least
19 /// squares).
20 #[error("numeric error: {0}")]
21 Numeric(String),
22
23 /// A column name was requested that does not exist in the dataset.
24 #[error("unknown column: {0}")]
25 UnknownColumn(String),
26
27 /// A column was used with a test that expects a different kind (e.g. a
28 /// continuous column passed to a discrete test).
29 #[error("wrong column kind: {0}")]
30 WrongColumnKind(String),
31
32 /// A column contained NaN / missing values at `Dataset` construction.
33 #[error("missing data: {0}")]
34 MissingData(String),
35
36 /// The (x, y, z) query itself is malformed (x == y, x/y inside z, or
37 /// duplicate entries in z).
38 #[error("invalid query: {0}")]
39 InvalidQuery(String),
40
41 /// A configuration value (e.g. a kernel length scale) is invalid.
42 #[error("invalid configuration: {0}")]
43 InvalidConfig(String),
44}