forked from M-Labs/nalgebra
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() {
|
||||
return Err(SparseFormatError::from_kind_and_msg(
|
||||
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() {
|
||||
return Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
Err(SparseFormatError::from_kind_and_msg(
|
||||
IndexOutOfBounds,
|
||||
"row index out of bounds",
|
||||
"Row index out of bounds.",
|
||||
))
|
||||
} else if !col_indices_in_bounds {
|
||||
Err(SparseFormatError::from_kind_and_msg(
|
||||
IndexOutOfBounds,
|
||||
"col index out of bounds",
|
||||
"Col index out of bounds.",
|
||||
))
|
||||
} else {
|
||||
Ok(Self {
|
||||
|
@ -181,7 +181,7 @@ impl<T> CscMatrix<T> {
|
||||
} else {
|
||||
Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
||||
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(
|
||||
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(
|
||||
K::InvalidStructure,
|
||||
"col offsets are not monotonically increasing",
|
||||
"Col offsets are not monotonically increasing.",
|
||||
),
|
||||
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
||||
K::InvalidStructure,
|
||||
"row indices are not monotonically increasing (sorted) within each column",
|
||||
"Row indices are not monotonically increasing (sorted) within each column.",
|
||||
),
|
||||
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 => {
|
||||
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 => {
|
||||
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() {
|
||||
return Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
return Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
return Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
@ -252,7 +252,7 @@ impl<T> CsrMatrix<T> {
|
||||
} else {
|
||||
Err(SparseFormatError::from_kind_and_msg(
|
||||
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 {
|
||||
InvalidOffsetArrayLength => E::from_kind_and_msg(
|
||||
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(
|
||||
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(
|
||||
K::InvalidStructure,
|
||||
"row offsets are not monotonically increasing",
|
||||
"Row offsets are not monotonically increasing.",
|
||||
),
|
||||
NonmonotonicMinorIndices => E::from_kind_and_msg(
|
||||
K::InvalidStructure,
|
||||
"column indices are not monotonically increasing (sorted) within each row",
|
||||
"Column indices are not monotonically increasing (sorted) within each row.",
|
||||
),
|
||||
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 => {
|
||||
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 => {
|
||||
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_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 {
|
||||
match self {
|
||||
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 => {
|
||||
write!(f, "first or last offset is incompatible with format")
|
||||
write!(f, "First or last offset is incompatible with format.")
|
||||
}
|
||||
SparsityPatternFormatError::NonmonotonicOffsets => {
|
||||
write!(f, "offsets are not monotonically increasing")
|
||||
write!(f, "Offsets are not monotonically increasing.")
|
||||
}
|
||||
SparsityPatternFormatError::MajorIndexOutOfBounds => {
|
||||
write!(f, "a major index is out of bounds")
|
||||
write!(f, "A major index is out of bounds.")
|
||||
}
|
||||
SparsityPatternFormatError::MinorIndexOutOfBounds => {
|
||||
write!(f, "a minor index is out of bounds")
|
||||
write!(f, "A minor index is out of bounds.")
|
||||
}
|
||||
SparsityPatternFormatError::DuplicateEntry => {
|
||||
write!(f, "input data contains duplicate entries")
|
||||
write!(f, "Input data contains duplicate entries.")
|
||||
}
|
||||
SparsityPatternFormatError::NonmonotonicMinorIndices => {
|
||||
write!(
|
||||
f,
|
||||
"minor indices are not monotonically increasing within each lane"
|
||||
"Minor indices are not monotonically increasing within each lane."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user