Skip to content

Commit 295f71b

Browse files
committed
Add blank lines in higher-dim array formatting
1 parent 1d77e93 commit 295f71b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/arrayformat.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ where
100100

101101
let n_to_be_printed = to_be_printed.len();
102102

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

105106
write!(f, "[")?;
@@ -117,10 +118,10 @@ where
117118
// We need to add a separator after each slice,
118119
// apart from the last one
119120
if j != n_to_be_printed - 1 {
120-
write!(f, ",\n")?
121+
write!(f, ",\n{}", blank_lines)?
121122
}
122123
},
123-
PrintableCell::Ellipses => write!(f, "{}...,\n", indent)?,
124+
PrintableCell::Ellipses => write!(f, "{}...,\n{}", indent, blank_lines)?,
124125
}
125126
}
126127
write!(f, "]")?;

tests/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn formatting()
1414
"[ 1, 2, 3, 4]");
1515
let a = a.reshape((4, 1, 1));
1616
assert_eq!(format!("{:4}", a),
17-
"[[[ 1]],\n [[ 2]],\n [[ 3]],\n [[ 4]]]");
17+
"[[[ 1]],\n\n [[ 2]],\n\n [[ 3]],\n\n [[ 4]]]");
1818

1919
let a = a.reshape((2, 2));
2020
assert_eq!(format!("{}", a),

0 commit comments

Comments
 (0)