Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnemecek committed Jan 5, 2025
1 parent 08e34d7 commit b6ebe64
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions nalgebra-sparse/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,32 +360,22 @@ impl From<SparsityPatternFormatError> for SparseFormatError {
}
}
}

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).")
}
SparsityPatternFormatError::InvalidOffsetFirstLast => {
write!(f, "First or last offset is incompatible with format.")
}
SparsityPatternFormatError::NonmonotonicOffsets => {
write!(f, "Offsets are not monotonically increasing.")
}
SparsityPatternFormatError::MinorIndexOutOfBounds => {
write!(f, "A minor index is out of bounds.")
write!(
f,
"{}",
match self {
Self::InvalidOffsetArrayLength =>
"Length of offset array is not equal to (major_dim + 1).",
Self::InvalidOffsetFirstLast => "First or last offset is incompatible with format.",
Self::NonmonotonicOffsets => "Offsets are not monotonically increasing.",
Self::MinorIndexOutOfBounds => "A minor index is out of bounds.",
Self::DuplicateEntry => "Input data contains duplicate entries.",
Self::NonmonotonicMinorIndices =>
"Minor indices are not monotonically increasing within each lane.",
}
SparsityPatternFormatError::DuplicateEntry => {
write!(f, "Input data contains duplicate entries.")
}
SparsityPatternFormatError::NonmonotonicMinorIndices => {
write!(
f,
"Minor indices are not monotonically increasing within each lane."
)
}
}
)
}
}

Expand Down

0 comments on commit b6ebe64

Please sign in to comment.