Skip to content

Commit 4e20503

Browse files
committed
Add blank lines in higher-dim array formatting
1 parent 526e332 commit 4e20503

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/arrayformat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ where
9999

100100
let n_to_be_printed = to_be_printed.len();
101101

102+
let blank_lines = "\n".repeat(shape.len() - 2);
102103
let indent = " ".repeat(depth + 1);
103104

104105
write!(f, "[")?;
@@ -120,10 +121,10 @@ where
120121
// We need to add a separator after each slice,
121122
// apart from the last one
122123
if j != n_to_be_printed - 1 {
123-
write!(f, ",\n")?
124+
write!(f, ",\n{}", blank_lines)?
124125
}
125126
}
126-
PrintableCell::Ellipses => write!(f, "{}...,\n", indent)?,
127+
PrintableCell::Ellipses => write!(f, "{}...,\n{}", indent, blank_lines)?,
127128
}
128129
}
129130
write!(f, "]")?;

tests/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn formatting() {
1313
let a = a.reshape((4, 1, 1));
1414
assert_eq!(
1515
format!("{:4}", a),
16-
"[[[ 1]],\n [[ 2]],\n [[ 3]],\n [[ 4]]]"
16+
"[[[ 1]],\n\n [[ 2]],\n\n [[ 3]],\n\n [[ 4]]]",
1717
);
1818

1919
let a = a.reshape((2, 2));

0 commit comments

Comments
 (0)