Skip to content

Commit 5ab1c88

Browse files
committed
tidy matrix display
1 parent cd3d367 commit 5ab1c88

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: ignite/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def format_item(item: Any, prefix: str = "") -> Optional[str]:
140140
elif item.dim() == 1:
141141
return f"{prefix}[" + ", ".join(f"{x.item():.4f}" for x in item) + "]"
142142
else:
143-
return f"{prefix}Shape: {item.shape}"
143+
return f"{prefix}Shape: {list(item.shape)}"
144144
elif isinstance(item, dict):
145145
for key, value in item.items():
146146
formatted_value = format_item(value, f"{key}: ")

Diff for: tests/ignite/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_convert_tensor():
6767
{"large_vector": torch.tensor(range(20))},
6868
["large_vector: [0.0000, 1.0000, 2.0000, 3.0000, 4.0000, 5.0000, 6.0000, 7.0000, 8.0000, 9.0000, ...]"],
6969
),
70-
({"large_matrix": torch.randn(5, 5)}, ["large_matrix: Shape: torch.Size([5, 5])"]),
70+
({"large_matrix": torch.randn(5, 5)}, ["large_matrix: Shape: [5, 5]"]),
7171
({"empty": []}, ["empty: "]),
7272
([], []),
7373
({"none": None}, ["none: "]),

0 commit comments

Comments
 (0)