From 3271b442446a702de08e1d92fe6fd4a4e508a9cf Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 20 Feb 2025 08:03:21 +0000 Subject: [PATCH 1/3] fix len to match iter function --- pacman/model/routing_info/routing_info.py | 2 +- .../routing_info_tests/test_routing_info.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pacman/model/routing_info/routing_info.py b/pacman/model/routing_info/routing_info.py index a81819061..f701c7199 100644 --- a/pacman/model/routing_info/routing_info.py +++ b/pacman/model/routing_info/routing_info.py @@ -217,4 +217,4 @@ def __iter__(self) -> Iterator[VertexRoutingInfo]: yield info def __len__(self) -> int: - return len(self._info) + sum(len(v) for v in self._info.values()) diff --git a/unittests/model_tests/routing_info_tests/test_routing_info.py b/unittests/model_tests/routing_info_tests/test_routing_info.py index 9fffc231d..c7e3bd843 100644 --- a/unittests/model_tests/routing_info_tests/test_routing_info.py +++ b/unittests/model_tests/routing_info_tests/test_routing_info.py @@ -154,6 +154,22 @@ def test_routing_info(self): self.assertEqual(len(routing_info), len(list(routing_info))) + + def test_multiple(self): + routing_info = RoutingInfo() + vertex1 = SimpleMachineVertex(ConstantSDRAM(0)) + key = 12345 + info = MachineVertexRoutingInfo( + BaseKeyAndMask(key, FULL_MASK), "Test", vertex1, 0) + routing_info.add_routing_info(info) + vertex2 = SimpleMachineVertex(ConstantSDRAM(0)) + key = 67890 + info = MachineVertexRoutingInfo( + BaseKeyAndMask(key, FULL_MASK), "Test2", vertex1, 0) + routing_info.add_routing_info(info) + self.assertEqual(len(routing_info), len(list(routing_info))) + + def test_base_key_and_mask(self): with self.assertRaises(PacmanConfigurationException): BaseKeyAndMask(0xF0, 0x40) From 6e4914f1ba66db26d5b4a65dc46c06766a85493d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 20 Feb 2025 08:07:29 +0000 Subject: [PATCH 2/3] flake8 --- unittests/model_tests/routing_info_tests/test_routing_info.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/unittests/model_tests/routing_info_tests/test_routing_info.py b/unittests/model_tests/routing_info_tests/test_routing_info.py index c7e3bd843..c733ab2c7 100644 --- a/unittests/model_tests/routing_info_tests/test_routing_info.py +++ b/unittests/model_tests/routing_info_tests/test_routing_info.py @@ -154,7 +154,6 @@ def test_routing_info(self): self.assertEqual(len(routing_info), len(list(routing_info))) - def test_multiple(self): routing_info = RoutingInfo() vertex1 = SimpleMachineVertex(ConstantSDRAM(0)) @@ -162,14 +161,12 @@ def test_multiple(self): info = MachineVertexRoutingInfo( BaseKeyAndMask(key, FULL_MASK), "Test", vertex1, 0) routing_info.add_routing_info(info) - vertex2 = SimpleMachineVertex(ConstantSDRAM(0)) key = 67890 info = MachineVertexRoutingInfo( BaseKeyAndMask(key, FULL_MASK), "Test2", vertex1, 0) routing_info.add_routing_info(info) self.assertEqual(len(routing_info), len(list(routing_info))) - def test_base_key_and_mask(self): with self.assertRaises(PacmanConfigurationException): BaseKeyAndMask(0xF0, 0x40) From f3ca6cbde069cd3ee53df927d425965844a68aeb Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 20 Feb 2025 08:08:46 +0000 Subject: [PATCH 3/3] make method return --- pacman/model/routing_info/routing_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/model/routing_info/routing_info.py b/pacman/model/routing_info/routing_info.py index f701c7199..810e1a3c7 100644 --- a/pacman/model/routing_info/routing_info.py +++ b/pacman/model/routing_info/routing_info.py @@ -217,4 +217,4 @@ def __iter__(self) -> Iterator[VertexRoutingInfo]: yield info def __len__(self) -> int: - sum(len(v) for v in self._info.values()) + return sum(len(v) for v in self._info.values())