From 590f1656aeee921cd2fd0dedb13392d8fe8a222c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 23 Oct 2023 12:21:18 +0100 Subject: [PATCH] simplify Chip str but include monitor --- spinn_machine/chip.py | 13 +++++++------ unittests/test_chip.py | 35 +++-------------------------------- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/spinn_machine/chip.py b/spinn_machine/chip.py index 8fad1feb..f8b723df 100644 --- a/spinn_machine/chip.py +++ b/spinn_machine/chip.py @@ -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__() diff --git a/unittests/test_chip.py b/unittests/test_chip.py index cb277b45..c4ff6a3d 100644 --- a/unittests/test_chip.py +++ b/unittests/test_chip.py @@ -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],