Skip to content

Commit

Permalink
simplify Chip str but include monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 23, 2023
1 parent 78b2765 commit 590f165
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
13 changes: 7 additions & 6 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,14 @@ 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} "
else:
ip_info = ""
return (
f"[Chip: x={self._x}, y={self._y}, "
f"sdram={self.sdram // (1024 * 1024)} MB, "
f"ip_address={self.ip_address}, router={self.router}, "
f"processors={list(self._p.values())}, "
f"nearest_ethernet={self._nearest_ethernet_x}:"
f"{self._nearest_ethernet_y}]")
f"[Chip: x={self._x}, y={self._y}, {ip_info}"
f"n_cores={self.n_processors}, "
f"mon={self.get_physical_core_id([0])}]")

def __repr__(self) -> str:
return self.__str__()
Expand Down
35 changes: 3 additions & 32 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,9 @@ def test_create_chip(self):
self.assertIsNone(new_chip[42])
print(new_chip.__repr__())
self.assertEqual(
new_chip.__repr__(),
"[Chip: x=0, y=1, sdram=0 MB, ip_address=192.162.240.253, "
"router=[Router: "
"available_entries=1024, links=["
"[Link: source_x=0, source_y=0, source_link_id=0, "
"destination_x=1, destination_y=1], "
"[Link: source_x=0, source_y=1, source_link_id=1, "
"destination_x=1, destination_y=0], "
"[Link: source_x=1, source_y=1, source_link_id=2, "
"destination_x=0, destination_y=0], "
"[Link: source_x=1, source_y=0, source_link_id=3, "
"destination_x=0, destination_y=1]"
"]], processors=["
"[CPU: id=0, clock_speed=200 MHz, monitor=True], "
"[CPU: id=1, clock_speed=200 MHz, monitor=False], "
"[CPU: id=2, clock_speed=200 MHz, monitor=False], "
"[CPU: id=3, clock_speed=200 MHz, monitor=False], "
"[CPU: id=4, clock_speed=200 MHz, monitor=False], "
"[CPU: id=5, clock_speed=200 MHz, monitor=False], "
"[CPU: id=6, clock_speed=200 MHz, monitor=False], "
"[CPU: id=7, clock_speed=200 MHz, monitor=False], "
"[CPU: id=8, clock_speed=200 MHz, monitor=False], "
"[CPU: id=9, clock_speed=200 MHz, monitor=False], "
"[CPU: id=10, clock_speed=200 MHz, monitor=False], "
"[CPU: id=11, clock_speed=200 MHz, monitor=False], "
"[CPU: id=12, clock_speed=200 MHz, monitor=False], "
"[CPU: id=13, clock_speed=200 MHz, monitor=False], "
"[CPU: id=14, clock_speed=200 MHz, monitor=False], "
"[CPU: id=15, clock_speed=200 MHz, monitor=False], "
"[CPU: id=16, clock_speed=200 MHz, monitor=False], "
"[CPU: id=17, clock_speed=200 MHz, monitor=False]], "
"nearest_ethernet=0:0]")
"[Chip: x=0, y=1, ip_address=192.162.240.253 "
"n_cores=18, mon=None]",
new_chip.__repr__(),)
self.assertEqual(new_chip.tag_ids, OrderedSet([1, 2, 3, 4, 5, 6, 7]))
self.assertEqual(
[p[0] for p in new_chip],
Expand Down

0 comments on commit 590f165

Please sign in to comment.