Skip to content

Commit d6c1e73

Browse files
committed
lib.memory: expand Memory.Init.__repr__().
Display `shape` and `depth` also. `depth` is redundant although useful for ease of reading (there are always `depth` elements shown), but `shape` was just lost.
1 parent 9969a06 commit d6c1e73

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

amaranth/lib/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __len__(self):
117117
return self._depth
118118

119119
def __repr__(self):
120-
return f"Memory.Init({self._elems!r})"
120+
return f"Memory.Init({self._elems!r}, shape={self._shape!r}, depth={self._depth})"
121121

122122

123123
def __init__(self, *, shape, depth, init, attrs=None, src_loc_at=0):

tests/test_lib_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def test_constructor(self):
290290
self.assertIsInstance(m.init, memory.Memory.Init)
291291
self.assertEqual(list(m.init), [1, 2, 3, 0])
292292
self.assertEqual(m.init._raw, [1, 2, 3, 0])
293-
self.assertRepr(m.init, "Memory.Init([1, 2, 3, 0])")
293+
self.assertRepr(m.init, "Memory.Init([1, 2, 3, 0], shape=8, depth=4)")
294294
self.assertEqual(m.r_ports, ())
295295
self.assertEqual(m.w_ports, ())
296296

0 commit comments

Comments
 (0)