diff --git a/pacman/model/routing_info/routing_info.py b/pacman/model/routing_info/routing_info.py index a81819061..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: - return len(self._info) + return 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..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,6 +154,19 @@ 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) + 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)