Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Mar 7, 2024
1 parent 6acd180 commit 65091c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
33 changes: 0 additions & 33 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} "
Expand Down
5 changes: 2 additions & 3 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 65091c2

Please sign in to comment.