From fe70a80e417f1daefba2c9117929d33283c891cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20L=C3=B6schner?= Date: Tue, 28 Dec 2021 12:12:31 +0100 Subject: [PATCH] Partial revert "Use custom serde errors, make all sparse errs lowercase" --- nalgebra-sparse/src/coo.rs | 8 ++++---- nalgebra-sparse/src/csc.rs | 16 ++++++++-------- nalgebra-sparse/src/csr.rs | 22 +++++++++++----------- nalgebra-sparse/src/pattern.rs | 16 ++++++++-------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 06788406..4ad382dc 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -124,12 +124,12 @@ impl CooMatrix { 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 CooMatrix { 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 { diff --git a/nalgebra-sparse/src/csc.rs b/nalgebra-sparse/src/csc.rs index 29861684..c3c843c7 100644 --- a/nalgebra-sparse/src/csc.rs +++ b/nalgebra-sparse/src/csc.rs @@ -181,7 +181,7 @@ impl CscMatrix { } 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.") } } } diff --git a/nalgebra-sparse/src/csr.rs b/nalgebra-sparse/src/csr.rs index 6be91f94..88c335b2 100644 --- a/nalgebra-sparse/src/csr.rs +++ b/nalgebra-sparse/src/csr.rs @@ -192,14 +192,14 @@ impl CsrMatrix { 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 CsrMatrix { 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 CsrMatrix { } 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.") } } } diff --git a/nalgebra-sparse/src/pattern.rs b/nalgebra-sparse/src/pattern.rs index da16df7c..82a93ffd 100644 --- a/nalgebra-sparse/src/pattern.rs +++ b/nalgebra-sparse/src/pattern.rs @@ -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." ) } }