use thiserror::Error;
#[derive(Debug, Error)]
pub enum SparseErrors {
#[error("data_2 slot is None but was requested")]
Data2NotAvailable,
#[error("The slice index ({index}) is out of bounds (length: {len})")]
SliceIndexOutOfBounds {
index: usize,
len: usize,
},
#[error("You provided a duplicated slice index {0}")]
DuplicateSliceIndex(usize),
#[error(
"The dimensions of the matrix do not support sparse multiplication (matrix a n_col: {n_col_a}; matrix b n_row: {n_row_b})"
)]
SparseMatrixMultiplication {
n_col_a: usize,
n_row_b: usize,
},
#[error("The indices (len: {indices_len}) and data (len: {data_len}) need to have same length")]
DimensionMisMatchSparse {
indices_len: usize,
data_len: usize,
},
#[error("The sparse indptr is inconsistent ({detail}): expected {expected}, got {got}")]
SparseIndptrInvalid {
detail: &'static str,
expected: usize,
got: usize,
},
#[error("The shape of the two sparse matrices must be the same.")]
ShapeMismatchSparse,
#[error("The SparseCompressedData2 must be in CSR format")]
SparseMatrixMustBeCsr,
#[error(
"Row {row} of the sparse matrix sums to {row_sum}, which is not positive, so it cannot be normalised to a row-stochastic form (isolated node, or the kernel weights underflowed)"
)]
SparseMatrixIsolatedRow {
row: usize,
row_sum: f64,
},
#[error("The CSR matrix is malformed: {0}")]
MalformedCsr(&'static str),
#[error("The SparseCompressedData2 must be in CSC format")]
SparseMatrixMustBeCsc,
#[error("Expected this shape {expected:?}; got {got:?}.")]
ShapeMismatch {
expected: (usize, usize),
got: (usize, usize),
},
}