From 65091c2db3d7db0b39375243306c2b6ac631dcc5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 7 Mar 2024 17:16:50 +0000 Subject: [PATCH] merge fixes --- spinn_machine/chip.py | 33 --------------------------------- unittests/test_chip.py | 5 ++--- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/spinn_machine/chip.py b/spinn_machine/chip.py index 220b40cb..46a8307a 100644 --- a/spinn_machine/chip.py +++ b/spinn_machine/chip.py @@ -385,39 +385,6 @@ def get_physical_core_string(self, virtual_p: int) -> str: return "" return f" (ph: {physical_p})" - def __iter__(self) -> Iterator[Tuple[int, Processor]]: - """ - Get an iterable of processor identifiers and processors - - :return: An iterable of ``(processor_id, processor)`` where: - * ``processor_id`` is the ID of a processor - * ``processor`` is the processor with the ID - :rtype: iterable(tuple(int,Processor)) - """ - yield from self._monitor_processors.items() - yield from self._user_processors.items() - - def __len__(self) -> int: - """ - The number of processors associated with this chip. - - :return: The number of items in the underlying iterator. - :rtype: int - """ - return len(self._monitor_processors) + len(self._user_processors) - - def __getitem__(self, processor_id: int) -> Processor: - if processor_id in self._user_processors: - return self._user_processors[processor_id] - if processor_id in self._monitor_processors: - return self._monitor_processors[processor_id] - # Note difference from get_processor_with_id(); this is to conform to - # standard Python semantics - raise KeyError(processor_id) - - def __contains__(self, processor_id: int) -> bool: - return self.is_processor_with_id(processor_id) - def __str__(self) -> str: if self._ip_address: ip_info = f"ip_address={self.ip_address} " diff --git a/unittests/test_chip.py b/unittests/test_chip.py index 18d63b6a..f74cf66b 100644 --- a/unittests/test_chip.py +++ b/unittests/test_chip.py @@ -55,8 +55,6 @@ def test_create_chip(self): self.assertEqual(new_chip.router, self._router) self.assertEqual(new_chip.n_placable_processors, self.n_processors - 1) self.assertEqual(new_chip.n_placable_processors, self.n_processors - 1) - with self.assertRaises(KeyError): - self.assertIsNone(new_chip[42]) print(new_chip.__repr__()) self.assertEqual( "[Chip: x=0, y=1, ip_address=192.162.240.253 " @@ -97,7 +95,8 @@ def test_processors(self): self.assertEqual(len(all_p), len(set(new_chip.all_processor_ids))) users = set(new_chip.placeable_processors) self.assertEqual(len(users), new_chip.n_placable_processors) - self.assertEqual(len(users), len(set(new_chip.placeable_processors_ids))) + self.assertEqual(len(users), + len(set(new_chip.placable_processors_ids))) monitors = set(new_chip.scamp_processors) self.assertEqual(users.union(monitors), all_p) self.assertEqual(len(monitors),