Partial revert "Use custom serde errors, make all sparse errs lowercase"
This commit is contained in:
parent
513178e03e
commit
fe70a80e41
|
@ -124,12 +124,12 @@ impl<T> CooMatrix<T> {
|
||||||
if row_indices.len() != col_indices.len() {
|
if row_indices.len() != col_indices.len() {
|
||||||
return Err(SparseFormatError::from_kind_and_msg(
|
return Err(SparseFormatError::from_kind_and_msg(
|
||||||
InvalidStructure,
|
InvalidStructure,
|
||||||
"number of row and col indices must be the same",
|
"Number of row and col indices must be the same.",
|
||||||
));
|
));
|
||||||
} else if col_indices.len() != values.len() {
|
} else if col_indices.len() != values.len() {
|
||||||
return Err(SparseFormatError::from_kind_and_msg(
|
return Err(SparseFormatError::from_kind_and_msg(
|
||||||
InvalidStructure,
|
InvalidStructure,
|
||||||
"number of col indices and values must be the same",
|
"Number of col indices and values must be the same.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,12 +139,12 @@ impl<T> CooMatrix<T> {
|
||||||
if !row_indices_in_bounds {
|
if !row_indices_in_bounds {
|
||||||
Err(SparseFormatError::from_kind_and_msg(
|
Err(SparseFormatError::from_kind_and_msg(
|
||||||
IndexOutOfBounds,
|
IndexOutOfBounds,
|
||||||
"row index out of bounds",
|
"Row index out of bounds.",
|
||||||
))
|
))
|
||||||
} else if !col_indices_in_bounds {
|
} else if !col_indices_in_bounds {
|
||||||
Err(SparseFormatError::from_kind_and_msg(
|
Err(SparseFormatError::from_kind_and_msg(
|
||||||
IndexOutOfBounds,
|
IndexOutOfBounds,
|
||||||
"col index out of bounds",
|
"Col index out of bounds.",
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl<T> CscMatrix<T> {
|
||||||
} else {
|
} else {
|
||||||
Err(SparseFormatError::from_kind_and_msg(
|
Err(SparseFormatError::from_kind_and_msg(
|
||||||
SparseFormatErrorKind::InvalidStructure,
|
SparseFormatErrorKind::InvalidStructure,
|
||||||
"number of values and row indices must be the same",
|
"Number of values and row indices must be the same",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,28 +587,28 @@ fn pattern_format_error_to_csc_error(err: SparsityPatternFormatError) -> SparseF
|
||||||
match err {
|
match err {
|
||||||
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"length of col offset array is not equal to ncols + 1",
|
"Length of col offset array is not equal to ncols + 1.",
|
||||||
),
|
),
|
||||||
InvalidOffsetFirstLast => E::from_kind_and_msg(
|
InvalidOffsetFirstLast => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"first or last col offset is inconsistent with format specification",
|
"First or last col offset is inconsistent with format specification.",
|
||||||
),
|
),
|
||||||
NonmonotonicOffsets => E::from_kind_and_msg(
|
NonmonotonicOffsets => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"col offsets are not monotonically increasing",
|
"Col offsets are not monotonically increasing.",
|
||||||
),
|
),
|
||||||
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"row indices are not monotonically increasing (sorted) within each column",
|
"Row indices are not monotonically increasing (sorted) within each column.",
|
||||||
),
|
),
|
||||||
MajorIndexOutOfBounds => {
|
MajorIndexOutOfBounds => {
|
||||||
E::from_kind_and_msg(K::IndexOutOfBounds, "column indices are out of bounds")
|
E::from_kind_and_msg(K::IndexOutOfBounds, "Column indices are out of bounds.")
|
||||||
}
|
}
|
||||||
MinorIndexOutOfBounds => {
|
MinorIndexOutOfBounds => {
|
||||||
E::from_kind_and_msg(K::IndexOutOfBounds, "row indices are out of bounds")
|
E::from_kind_and_msg(K::IndexOutOfBounds, "Row indices are out of bounds.")
|
||||||
}
|
}
|
||||||
PatternDuplicateEntry => {
|
PatternDuplicateEntry => {
|
||||||
E::from_kind_and_msg(K::DuplicateEntry, "matrix data contains duplicate entries")
|
E::from_kind_and_msg(K::DuplicateEntry, "Matrix data contains duplicate entries.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,14 +192,14 @@ impl<T> CsrMatrix<T> {
|
||||||
if col_indices.len() != values.len() {
|
if col_indices.len() != values.len() {
|
||||||
return Err(SparseFormatError::from_kind_and_msg(
|
return Err(SparseFormatError::from_kind_and_msg(
|
||||||
SparseFormatErrorKind::InvalidStructure,
|
SparseFormatErrorKind::InvalidStructure,
|
||||||
"number of values and column indices must be the same",
|
"Number of values and column indices must be the same",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if row_offsets.len() == 0 {
|
if row_offsets.len() == 0 {
|
||||||
return Err(SparseFormatError::from_kind_and_msg(
|
return Err(SparseFormatError::from_kind_and_msg(
|
||||||
SparseFormatErrorKind::InvalidStructure,
|
SparseFormatErrorKind::InvalidStructure,
|
||||||
"number of offsets should be greater than 0",
|
"Number of offsets should be greater than 0",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ impl<T> CsrMatrix<T> {
|
||||||
if next_offset > count {
|
if next_offset > count {
|
||||||
return Err(SparseFormatError::from_kind_and_msg(
|
return Err(SparseFormatError::from_kind_and_msg(
|
||||||
SparseFormatErrorKind::InvalidStructure,
|
SparseFormatErrorKind::InvalidStructure,
|
||||||
"no row offset should be greater than the number of column indices",
|
"No row offset should be greater than the number of column indices",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if offset > next_offset {
|
if offset > next_offset {
|
||||||
|
@ -252,7 +252,7 @@ impl<T> CsrMatrix<T> {
|
||||||
} else {
|
} else {
|
||||||
Err(SparseFormatError::from_kind_and_msg(
|
Err(SparseFormatError::from_kind_and_msg(
|
||||||
SparseFormatErrorKind::InvalidStructure,
|
SparseFormatErrorKind::InvalidStructure,
|
||||||
"number of values and column indices must be the same",
|
"Number of values and column indices must be the same",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,28 +658,28 @@ fn pattern_format_error_to_csr_error(err: SparsityPatternFormatError) -> SparseF
|
||||||
match err {
|
match err {
|
||||||
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"length of row offset array is not equal to nrows + 1",
|
"Length of row offset array is not equal to nrows + 1.",
|
||||||
),
|
),
|
||||||
InvalidOffsetFirstLast => E::from_kind_and_msg(
|
InvalidOffsetFirstLast => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"first or last row offset is inconsistent with format specification",
|
"First or last row offset is inconsistent with format specification.",
|
||||||
),
|
),
|
||||||
NonmonotonicOffsets => E::from_kind_and_msg(
|
NonmonotonicOffsets => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"row offsets are not monotonically increasing",
|
"Row offsets are not monotonically increasing.",
|
||||||
),
|
),
|
||||||
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
||||||
K::InvalidStructure,
|
K::InvalidStructure,
|
||||||
"column indices are not monotonically increasing (sorted) within each row",
|
"Column indices are not monotonically increasing (sorted) within each row.",
|
||||||
),
|
),
|
||||||
MajorIndexOutOfBounds => {
|
MajorIndexOutOfBounds => {
|
||||||
E::from_kind_and_msg(K::IndexOutOfBounds, "row indices are out of bounds")
|
E::from_kind_and_msg(K::IndexOutOfBounds, "Row indices are out of bounds.")
|
||||||
}
|
}
|
||||||
MinorIndexOutOfBounds => {
|
MinorIndexOutOfBounds => {
|
||||||
E::from_kind_and_msg(K::IndexOutOfBounds, "column indices are out of bounds")
|
E::from_kind_and_msg(K::IndexOutOfBounds, "Column indices are out of bounds.")
|
||||||
}
|
}
|
||||||
PatternDuplicateEntry => {
|
PatternDuplicateEntry => {
|
||||||
E::from_kind_and_msg(K::DuplicateEntry, "matrix data contains duplicate entries")
|
E::from_kind_and_msg(K::DuplicateEntry, "Matrix data contains duplicate entries.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl SparsityPattern {
|
||||||
new_offsets,
|
new_offsets,
|
||||||
new_indices,
|
new_indices,
|
||||||
)
|
)
|
||||||
.expect("internal error: Transpose should never fail")
|
.expect("Internal error: Transpose should never fail.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,27 +363,27 @@ impl fmt::Display for SparsityPatternFormatError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
SparsityPatternFormatError::InvalidOffsetArrayLength => {
|
SparsityPatternFormatError::InvalidOffsetArrayLength => {
|
||||||
write!(f, "length of offset array is not equal to (major_dim + 1)")
|
write!(f, "Length of offset array is not equal to (major_dim + 1).")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::InvalidOffsetFirstLast => {
|
SparsityPatternFormatError::InvalidOffsetFirstLast => {
|
||||||
write!(f, "first or last offset is incompatible with format")
|
write!(f, "First or last offset is incompatible with format.")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::NonmonotonicOffsets => {
|
SparsityPatternFormatError::NonmonotonicOffsets => {
|
||||||
write!(f, "offsets are not monotonically increasing")
|
write!(f, "Offsets are not monotonically increasing.")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::MajorIndexOutOfBounds => {
|
SparsityPatternFormatError::MajorIndexOutOfBounds => {
|
||||||
write!(f, "a major index is out of bounds")
|
write!(f, "A major index is out of bounds.")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::MinorIndexOutOfBounds => {
|
SparsityPatternFormatError::MinorIndexOutOfBounds => {
|
||||||
write!(f, "a minor index is out of bounds")
|
write!(f, "A minor index is out of bounds.")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::DuplicateEntry => {
|
SparsityPatternFormatError::DuplicateEntry => {
|
||||||
write!(f, "input data contains duplicate entries")
|
write!(f, "Input data contains duplicate entries.")
|
||||||
}
|
}
|
||||||
SparsityPatternFormatError::NonmonotonicMinorIndices => {
|
SparsityPatternFormatError::NonmonotonicMinorIndices => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"minor indices are not monotonically increasing within each lane"
|
"Minor indices are not monotonically increasing within each lane."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue