Skip to content

Commit 23234d5

Browse files
committed
Add blank lines in higher-dim array formatting
1 parent 27d3106 commit 23234d5

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
@@ -102,6 +102,7 @@ where
102102

103103
let n_to_be_printed = to_be_printed.len();
104104

105+
let blank_lines = "\n".repeat(shape.len() - 2);
105106
let indent = " ".repeat(depth + 1);
106107

107108
write!(f, "[")?;
@@ -123,10 +124,10 @@ where
123124
// We need to add a separator after each slice,
124125
// apart from the last one
125126
if j != n_to_be_printed - 1 {
126-
write!(f, ",\n")?
127+
write!(f, ",\n{}", blank_lines)?
127128
}
128129
}
129-
PrintableCell::Ellipses => write!(f, "{}...,\n", indent)?,
130+
PrintableCell::Ellipses => write!(f, "{}...,\n{}", indent, blank_lines)?,
130131
}
131132
}
132133
write!(f, "]")?;

tests/format.rs

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

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

0 commit comments

Comments
 (0)