From fc84b8decf348468596b5420e431b4f912c3eb9d Mon Sep 17 00:00:00 2001 From: Catherine Date: Fri, 22 Mar 2024 21:15:17 +0000 Subject: [PATCH] lib.memory: remove `Memory.Init.depth`. This attribute is fully redundant with `.__len__()`, and is out of place on a `list`-like container like `Memory.Init`. The `.shape` attribute, however, provides a unique function. --- amaranth/lib/memory.py | 5 ----- tests/test_lib_memory.py | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/amaranth/lib/memory.py b/amaranth/lib/memory.py index 6ffdb9d..823c5b5 100644 --- a/amaranth/lib/memory.py +++ b/amaranth/lib/memory.py @@ -88,11 +88,6 @@ class Memory(wiring.Component): def shape(self): return self._shape - # TODO: redundant with __len__ - @property - def depth(self): - return self._depth - def __getitem__(self, index): return self._elems[index] diff --git a/tests/test_lib_memory.py b/tests/test_lib_memory.py index a07d059..d0cdcf9 100644 --- a/tests/test_lib_memory.py +++ b/tests/test_lib_memory.py @@ -285,7 +285,7 @@ class MemoryTestCase(FHDLTestCase): self.assertEqual(m.shape, 8) self.assertEqual(m.depth, 4) self.assertEqual(m.init.shape, 8) - self.assertEqual(m.init.depth, 4) + self.assertEqual(len(m.init), 4) self.assertEqual(m.attrs, {}) self.assertIsInstance(m.init, memory.Memory.Init) self.assertEqual(list(m.init), [1, 2, 3, 0])