Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T machine #276

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ jobs:
coverage-package: spinn_machine
flake8-packages: spinn_machine unittests
pylint-packages: spinn_machine
mypy-packages: unittests
mypy-full_packages: spinn_machine
mypy-full_packages: spinn_machine unittests
secrets: inherit
2 changes: 1 addition & 1 deletion mypyd.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

utils="../SpiNNUtils/spinn_utilities"

mypy --python-version 3.8 --disallow-untyped-defs $utils spinn_machine
mypy --python-version 3.8 --disallow-untyped-defs $utils spinn_machine unittests
54 changes: 27 additions & 27 deletions unittests/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

class TestSimulatorData(unittest.TestCase):

def setUp(self):
def setUp(self) -> None:
unittest_setup()

def test_setup(self):
def test_setup(self) -> None:
# What happens before setup depends on the previous test
# Use manual_check to verify this without dependency
MachineDataWriter.setup()
Expand All @@ -38,13 +38,13 @@ def test_setup(self):
with self.assertRaises(DataNotYetAvialable):
MachineDataView.get_chip_at(1, 1)

def test_mock(self):
set_config("Machine", "version", FIVE)
def test_mock(self) -> None:
set_config("Machine", "version", str(FIVE))
self.assertEqual(3, MachineDataView.get_chip_at(3, 5).x)
self.assertEqual(48, MachineDataView.get_machine().n_chips)

def test_machine(self):
set_config("Machine", "version", THREE)
def test_machine(self) -> None:
set_config("Machine", "version", str(THREE))
writer = MachineDataWriter.setup()

with self.assertRaises(DataNotYetAvialable):
Expand All @@ -56,10 +56,10 @@ def test_machine(self):
with self.assertRaises(KeyError):
MachineDataView.get_chip_at(4, 4)
with self.assertRaises(TypeError):
writer.set_machine("bacon")
writer.set_machine("bacon") # type: ignore[arg-type]
self.assertTrue(MachineDataView.has_machine())

def test_where_is_mocked(self):
def test_where_is_mocked(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
writer = MachineDataWriter.mock()
self.assertEqual(
Expand All @@ -75,9 +75,9 @@ def test_where_is_mocked(self):
MachineDataView.where_is_xy(11, 11))
self.assertEqual(
"global chip 2, 8 on 127.0.0.0 is chip 6, 4 on 127.0.8.4",
MachineDataView.where_is_chip(machine.get_chip_at(2, 8)))
MachineDataView.where_is_chip(machine[2, 8]))

def test_where_is_setup(self):
def test_where_is_setup(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
writer = MachineDataWriter.setup()
self.assertEqual(
Expand All @@ -93,15 +93,15 @@ def test_where_is_setup(self):
MachineDataView.where_is_xy(-1, 11))
self.assertEqual(
"global chip 2, 8 on 127.0.0.0 is chip 6, 4 on 127.0.8.4",
MachineDataView.where_is_chip(machine.get_chip_at(2, 8)))
MachineDataView.where_is_chip(machine[2, 8]))
self.assertEqual(
"None",
MachineDataView.where_is_chip(None)
MachineDataView.where_is_chip(None) # type: ignore[arg-type]
)

def test_v_to_p_spin1(self):
def test_v_to_p_spin1(self) -> None:
writer = MachineDataWriter.setup()
set_config("Machine", "version", FIVE)
set_config("Machine", "version", str(FIVE))
# Before setting
with self.assertRaises(DataNotYetAvialable):
writer.get_physical_core_id((1, 2), 3)
Expand All @@ -125,9 +125,9 @@ def test_v_to_p_spin1(self):
self.assertEqual("",
writer.get_physical_string((1, 2), 19))

def test_v_to_p_spin2(self):
def test_v_to_p_spin2(self) -> None:
writer = MachineDataWriter.setup()
set_config("Machine", "version", SPIN2_48CHIP)
set_config("Machine", "version", str(SPIN2_48CHIP))

# exists
self.assertEqual((7, 6, 2), writer.get_physical_quad(3))
Expand All @@ -138,44 +138,44 @@ def test_v_to_p_spin2(self):
self.assertEqual("",
writer.get_physical_string((1, 2), 234))

def test_mock_any(self):
def test_mock_any(self) -> None:
# Should work with any version
set_config("Machine", "versions", VersionStrings.ANY.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 1)

def test_mock_4_or_more(self):
def test_mock_4_or_more(self) -> None:
# Should work with any version that has 4 plus Chips
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 4)

def test_mock_big(self):
def test_mock_big(self) -> None:
# Should work with any version
set_config("Machine", "versions", VersionStrings.BIG.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 48)

def test_mock3(self):
def test_mock3(self) -> None:
# Should work with any version
set_config("Machine", "version", 3)
set_config("Machine", "version", "3")
# check there is a value not what it is
MachineDataView.get_machine()

def test_mock5(self):
set_config("Machine", "version", 5)
def test_mock5(self) -> None:
set_config("Machine", "version", "5")
# check there is a value not what it is
MachineDataView.get_machine()

def test_mock201(self):
set_config("Machine", "version", 201)
def test_mock201(self) -> None:
set_config("Machine", "version", "201")
# check there is a value not what it is
MachineDataView.get_machine()

def test_get_monitors(self):
def test_get_monitors(self) -> None:
writer = MachineDataWriter.setup()
self.assertEqual(0, MachineDataView.get_all_monitor_cores())
self.assertEqual(0, MachineDataView.get_ethernet_monitor_cores())
Expand All @@ -187,7 +187,7 @@ def test_get_monitors(self):
self.assertEqual(2, MachineDataView.get_all_monitor_cores())
self.assertEqual(3, MachineDataView.get_ethernet_monitor_cores())

def test_no_version(self):
def test_no_version(self) -> None:
set_config("Machine", "machineName", "SpiNNaker1M")
try:
MachineDataView.get_machine_version()
Expand Down
20 changes: 10 additions & 10 deletions unittests/tag_tests/test_iptag.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
class TestingIptag(unittest.TestCase):
""" Tests of IPTag
"""
def setUp(self):
def setUp(self) -> None:
unittest_setup()

def test_create_valid_iptag(self):
def test_create_valid_iptag(self) -> None:
""" test if an IP tag with valid inputs works

:rtype: None
"""
iptag = IPTag("", 0, 0, 0, "", 1)
self.assertIsNotNone(iptag)

def test_retrival_of_board_address(self):
def test_retrival_of_board_address(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -44,7 +44,7 @@ def test_retrival_of_board_address(self):
board_address = iptag.board_address
self.assertEqual("", board_address)

def test_retrival_of_ip_address(self):
def test_retrival_of_ip_address(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -54,7 +54,7 @@ def test_retrival_of_ip_address(self):
ip_address = iptag.ip_address
self.assertEqual("", ip_address)

def test_retrival_of_tag(self):
def test_retrival_of_tag(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -64,7 +64,7 @@ def test_retrival_of_tag(self):
tag = iptag.tag
self.assertEqual(tag, 0)

def test_retrival_of_port(self):
def test_retrival_of_port(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -74,7 +74,7 @@ def test_retrival_of_port(self):
port = iptag.port
self.assertEqual(port, 1)

def test_retrival_of_strip_sdp(self):
def test_retrival_of_strip_sdp(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -84,14 +84,14 @@ def test_retrival_of_strip_sdp(self):
strip_sdp = iptag.strip_sdp
self.assertEqual(strip_sdp, False)

def test_tag_rendering(self):
def test_tag_rendering(self) -> None:
iptag = IPTag("localhost", 1, 2, 3, "abc", 4, True)
assert iptag.__repr__() == (
"IPTag(board_address=localhost, destination_x=1, destination_y=2, "
"tag=3, port=4, ip_address=abc, strip_sdp=True, "
"traffic_identifier=DEFAULT)")

def test_in_dict(self):
def test_in_dict(self) -> None:
d = dict()
iptag_1 = IPTag("", 0, 0, 0, "", 1)
d[iptag_1] = 1
Expand All @@ -102,7 +102,7 @@ def test_in_dict(self):
assert d[iptag_2] == 10
assert len(d) == 2

def test_no_equals(self):
def test_no_equals(self) -> None:
iptag = IPTag("", 0, 0, 0, "", 1)
self.assertNotEqual(iptag, "foo")

Expand Down
20 changes: 10 additions & 10 deletions unittests/tag_tests/test_reverse_iptag.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class TestingReverseIptag(unittest.TestCase):
""" Tests of ReverseIPTag
"""

def setUp(self):
def setUp(self) -> None:
unittest_setup()

def test_create_valid_reverse_iptag(self):
def test_create_valid_reverse_iptag(self) -> None:
""" test if a reverse IP tag with valid inputs works

:rtype: None
"""
reverse_ip_tag = ReverseIPTag("", 0, 1, 0, 0, 1)
self.assertIsNotNone(reverse_ip_tag)

def test_retrival_of_board_address(self):
def test_retrival_of_board_address(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -45,7 +45,7 @@ def test_retrival_of_board_address(self):
board_address = reverse_ip_tag.board_address
self.assertEqual("", board_address)

def test_retrival_of_tag(self):
def test_retrival_of_tag(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -55,7 +55,7 @@ def test_retrival_of_tag(self):
tag = reverse_ip_tag.tag
self.assertEqual(0, tag)

def test_retrival_of_port(self):
def test_retrival_of_port(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -65,7 +65,7 @@ def test_retrival_of_port(self):
port = reverse_ip_tag.port
self.assertEqual(port, 1)

def test_retrival_of_dest_x(self):
def test_retrival_of_dest_x(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -75,7 +75,7 @@ def test_retrival_of_dest_x(self):
destination_x = reverse_ip_tag.destination_x
self.assertEqual(destination_x, 0)

def test_retrival_of_dest_y(self):
def test_retrival_of_dest_y(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -85,7 +85,7 @@ def test_retrival_of_dest_y(self):
destination_y = reverse_ip_tag.destination_y
self.assertEqual(destination_y, 0)

def test_retrival_of_dest_p(self):
def test_retrival_of_dest_p(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -95,7 +95,7 @@ def test_retrival_of_dest_p(self):
destination_p = reverse_ip_tag.destination_p
self.assertEqual(destination_p, 1)

def test_retrival_of_sdp_port(self):
def test_retrival_of_sdp_port(self) -> None:
""" test if the board address retrieval works

:rtype: None
Expand All @@ -105,7 +105,7 @@ def test_retrival_of_sdp_port(self):
sdp_port = reverse_ip_tag.sdp_port
self.assertEqual(sdp_port, 1)

def test_tag_rendering(self):
def test_tag_rendering(self) -> None:
riptag = ReverseIPTag("somewhere.local", 2, 3, 4, 5, 6)
assert riptag.__repr__() == (
"ReverseIPTag(board_address=somewhere.local, tag=2, port=3, "
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_cfg_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

class TestCfgChecker(unittest.TestCase):

def setUp(self):
def setUp(self) -> None:
unittest_setup()

def test_cfg_checker(self):
def test_cfg_checker(self) -> None:
unittests_dir = os.path.dirname(__file__)
spinn_machine_dir = spinn_machine.__path__[0]
run_config_checks(directories=[spinn_machine_dir, unittests_dir])
15 changes: 7 additions & 8 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class TestingChip(unittest.TestCase):

def setUp(self):
def setUp(self) -> None:
unittest_setup()
set_config("Machine", "versions", VersionStrings.ANY.text)
self._x = 0
Expand All @@ -45,7 +45,7 @@ def setUp(self):
def _create_chip(self, x, y, processors, r, sdram, ip):
return Chip(x, y, [0], range(1, processors), r, sdram, 0, 0, ip)

def test_create_chip(self):
def test_create_chip(self) -> None:
new_chip = self._create_chip(self._x, self._y, self.n_processors,
self._router, self._sdram, self._ip)

Expand All @@ -64,18 +64,17 @@ def test_create_chip(self):
self.assertEqual(new_chip.tag_ids, OrderedSet([1, 2, 3, 4, 5, 6, 7]))
self.assertTrue(new_chip.is_processor_with_id(3))

def test_0_down(self):
def test_0_down(self) -> None:
Chip(1, 1, [1], range(3, self.n_processors), self._router,
self._sdram, 0, 0, self._ip)

def test_1_chip(self):
def test_1_chip(self) -> None:
# Chip with just 1 processor
new_chip = Chip(1, 1, [0], [], self._router, self._sdram, 0, 0,
self._ip)
with self.assertRaises(Exception):
new_chip.get_first_none_monitor_processor()
self.assertEqual((), new_chip.placable_processors_ids)

def test_processors(self):
def test_processors(self) -> None:
new_chip = self._create_chip(self._x, self._y, self.n_processors,
self._router, self._sdram, self._ip)
all_p = set(new_chip.all_processor_ids)
Expand All @@ -85,7 +84,7 @@ def test_processors(self):
monitors = set(new_chip.scamp_processors_ids)
self.assertEqual(users.union(monitors), all_p)

def test_is_xy(self):
def test_is_xy(self) -> None:
chip24 = self._create_chip(
2, 4, self.n_processors, self._router, self._sdram, None)
chip36 = self._create_chip(
Expand Down
Loading
Loading