Simplify Matrix Debug output

This commit is contained in:
Owen Brooks 2022-06-15 20:14:37 +10:00
parent 65e90d53a9
commit 97e2a8ff44
1 changed files with 5 additions and 20 deletions

View File

@ -199,11 +199,10 @@ impl<T: fmt::Debug, R: Dim, C: Dim, S: RawStorage<T, R, C> + fmt::Debug> fmt::De
for Matrix<T, R, C, S> for Matrix<T, R, C, S>
{ {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Matrix {{ ")?;
if f.alternate() { if f.alternate() {
write!(f, "\n ")?; writeln!(f, "")?;
} }
write!(f, "data: [")?; write!(f, "[")?;
let nrows = self.nrows(); let nrows = self.nrows();
let ncols = self.ncols(); let ncols = self.ncols();
for i in 0..nrows { for i in 0..nrows {
@ -223,19 +222,7 @@ impl<T: fmt::Debug, R: Dim, C: Dim, S: RawStorage<T, R, C> + fmt::Debug> fmt::De
write!(f, "\n ")?; write!(f, "\n ")?;
} }
} }
write!(f, "], ")?; write!(f, "]")
if f.alternate() {
write!(f, "\n ")?;
}
write!(f, "nrows: {:?}, ", nrows)?;
if f.alternate() {
write!(f, "\n ")?;
}
write!(f, "ncols: {:?} ", ncols)?;
if f.alternate() {
writeln!(f, "")?;
}
write!(f, "}}")
} }
} }
@ -2028,9 +2015,7 @@ mod tests {
1e6 2e5 1e6 2e5
2e-5 1e0 2e-5 1e0
"
"
) )
} }
} }