From 867c9fa635b7e4176d2f0fb6df9c546b0637a7ec Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 8 Dec 2023 13:50:13 +0000 Subject: [PATCH 1/4] overrides typing --- .../application/application_2d_fpga_vertex.py | 4 ++-- .../application_2d_spinnaker_link_vertex.py | 4 ++-- pacman/model/graphs/common/mdslice.py | 6 ++++-- pacman/model/graphs/common/slice.py | 6 ++++-- .../constant_sdram_machine_partition.py | 2 +- pacman/model/graphs/machine/machine_edge.py | 2 +- .../graphs/machine/simple_machine_vertex.py | 20 ++++++++++++------- .../abstract_splitter_common.py | 2 +- .../splitter_external_device.py | 2 +- .../splitter_one_app_one_machine.py | 5 +++-- .../splitter_one_to_one_legacy.py | 20 ++++++++++--------- pacman/model/resources/constant_sdram.py | 8 +++++--- pacman/model/resources/multi_region_sdram.py | 5 +++-- pacman/model/resources/variable_sdram.py | 5 +++-- 14 files changed, 54 insertions(+), 37 deletions(-) diff --git a/pacman/model/graphs/application/application_2d_fpga_vertex.py b/pacman/model/graphs/application/application_2d_fpga_vertex.py index 91382ac3b..75e7ebb1e 100644 --- a/pacman/model/graphs/application/application_2d_fpga_vertex.py +++ b/pacman/model/graphs/application/application_2d_fpga_vertex.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import List, Optional +from typing import List, Optional, Tuple from spinn_utilities.overrides import overrides from .application_fpga_vertex import ApplicationFPGAVertex from pacman.model.graphs.application.abstract import Abstract2DDeviceVertex @@ -90,7 +90,7 @@ def sub_height(self) -> int: @property @overrides(ApplicationFPGAVertex.atoms_shape) - def atoms_shape(self): + def atoms_shape(self) -> Tuple[int, ...]: return (self.__width, self.__height) @overrides(ApplicationFPGAVertex.get_incoming_slice_for_link) diff --git a/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py b/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py index ca1f08878..a1643fecc 100644 --- a/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py +++ b/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Optional +from typing import Optional, Tuple from spinn_utilities.overrides import overrides from .application_spinnaker_link_vertex import ApplicationSpiNNakerLinkVertex from pacman.model.graphs.application.abstract import Abstract2DDeviceVertex @@ -88,7 +88,7 @@ def sub_height(self) -> int: @property @overrides(ApplicationSpiNNakerLinkVertex.atoms_shape) - def atoms_shape(self): + def atoms_shape(self) -> Tuple[int, ...]: return (self.__width, self.__height) @overrides(ApplicationSpiNNakerLinkVertex.get_incoming_slice) diff --git a/pacman/model/graphs/common/mdslice.py b/pacman/model/graphs/common/mdslice.py index 2faa7eaaa..306d87bf4 100644 --- a/pacman/model/graphs/common/mdslice.py +++ b/pacman/model/graphs/common/mdslice.py @@ -160,7 +160,8 @@ def from_string(cls, as_str: str) -> Union[MDSlice, Slice]: atoms_shape) @overrides(Slice.get_relative_indices) - def get_relative_indices(self, app_vertex_indices): + def get_relative_indices(self, app_vertex_indices: NDArray[numpy.integer] + ) -> NDArray[numpy.integer]: n_dims = len(self._atoms_shape) remainders = app_vertex_indices cum_last_core = 1 @@ -185,7 +186,8 @@ def get_relative_indices(self, app_vertex_indices): return rel_index.astype(numpy.uint32) @overrides(Slice.get_raster_indices) - def get_raster_indices(self, relative_indices): + def get_raster_indices(self, relative_indices: NDArray[numpy.integer] + ) -> NDArray[numpy.integer]: n_dims = len(self._atoms_shape) remainders = relative_indices cum_last_size = 1 diff --git a/pacman/model/graphs/common/slice.py b/pacman/model/graphs/common/slice.py index 617111f93..288ae86f2 100644 --- a/pacman/model/graphs/common/slice.py +++ b/pacman/model/graphs/common/slice.py @@ -205,7 +205,8 @@ def from_string(cls, as_str: str) -> Slice: hi_atom = int(parts[1]) return Slice(lo_atom, hi_atom) - def get_relative_indices(self, app_vertex_indices): + def get_relative_indices(self, app_vertex_indices: NDArray[numpy.interger] + ) -> NDArray[numpy.integer]: """ Convert from raster indices to slice-level indices. @@ -218,7 +219,8 @@ def get_relative_indices(self, app_vertex_indices): """ return app_vertex_indices - self._lo_atom - def get_raster_indices(self, relative_indices): + def get_raster_indices(self, relative_indices: NDArray[numpy.integer] + ) -> NDArray[numpy.integer]: """ Convert from slice-level indices to raster indices. diff --git a/pacman/model/graphs/machine/constant_sdram_machine_partition.py b/pacman/model/graphs/machine/constant_sdram_machine_partition.py index c9a7f47d3..fa0481888 100644 --- a/pacman/model/graphs/machine/constant_sdram_machine_partition.py +++ b/pacman/model/graphs/machine/constant_sdram_machine_partition.py @@ -49,7 +49,7 @@ def __init__(self, identifier: str, pre_vertex: V): self._sdram_base_address: Optional[int] = None @overrides(AbstractSingleSourcePartition.add_edge) - def add_edge(self, edge): + def add_edge(self, edge: E): if self._sdram_size is None: self._sdram_size = edge.sdram_size elif self._sdram_size != edge.sdram_size: diff --git a/pacman/model/graphs/machine/machine_edge.py b/pacman/model/graphs/machine/machine_edge.py index b5f24ab04..44aa83b02 100644 --- a/pacman/model/graphs/machine/machine_edge.py +++ b/pacman/model/graphs/machine/machine_edge.py @@ -51,7 +51,7 @@ def __init__(self, pre_vertex: MachineVertex, post_vertex: MachineVertex, @property @overrides(AbstractEdge.label) - def label(self): + def label(self) -> Optional[str]: return self._label @property diff --git a/pacman/model/graphs/machine/simple_machine_vertex.py b/pacman/model/graphs/machine/simple_machine_vertex.py index ea6434bc9..8e30e2969 100644 --- a/pacman/model/graphs/machine/simple_machine_vertex.py +++ b/pacman/model/graphs/machine/simple_machine_vertex.py @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Iterable, Optional from .machine_vertex import MachineVertex from spinn_utilities.overrides import overrides +from pacman.model.resources import AbstractSDRAM +from pacman.model.resources import IPtagResource +from pacman.model.resources import ReverseIPtagResource class SimpleMachineVertex(MachineVertex): @@ -27,29 +31,31 @@ class SimpleMachineVertex(MachineVertex): __slots__ = ("_iptags", "_reverse_iptags", "_sdram") def __init__(self, sdram, label=None, - app_vertex=None, vertex_slice=None, iptags=None, - reverse_iptags=None): + app_vertex=None, vertex_slice=None, + iptags: Optional[Iterable[IPtagResource]] = None, + reverse_iptags: Optional[Iterable[ReverseIPtagResource]] + = None): super().__init__( label=label, app_vertex=app_vertex, vertex_slice=vertex_slice) self._sdram = sdram - self._iptags = [] + self._iptags: Iterable[IPtagResource] = [] if iptags: self._iptags = iptags - self._reverse_iptags = [] + self._reverse_iptags: Iterable[ReverseIPtagResource] = [] if reverse_iptags: self._reverse_iptags = reverse_iptags @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> AbstractSDRAM: return self._sdram @property @overrides(MachineVertex.iptags) - def iptags(self): + def iptags(self) -> Iterable[IPtagResource]: return self._iptags @property @overrides(MachineVertex.reverse_iptags) - def reverse_iptags(self): + def reverse_iptags(self) -> Iterable[ReverseIPtagResource]: return self._reverse_iptags diff --git a/pacman/model/partitioner_splitters/abstract_splitter_common.py b/pacman/model/partitioner_splitters/abstract_splitter_common.py index 4bfe2e367..e6ec84f44 100644 --- a/pacman/model/partitioner_splitters/abstract_splitter_common.py +++ b/pacman/model/partitioner_splitters/abstract_splitter_common.py @@ -189,7 +189,7 @@ def machine_vertices_for_recording( raise NotImplementedError @abstractmethod - def reset_called(self): + def reset_called(self) -> None: """ Reset the splitter to be as if it has not operated a splitting yet. """ diff --git a/pacman/model/partitioner_splitters/splitter_external_device.py b/pacman/model/partitioner_splitters/splitter_external_device.py index 4e055b985..604659502 100644 --- a/pacman/model/partitioner_splitters/splitter_external_device.py +++ b/pacman/model/partitioner_splitters/splitter_external_device.py @@ -163,5 +163,5 @@ def machine_vertices_for_recording( return [] @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> bool: pass diff --git a/pacman/model/partitioner_splitters/splitter_one_app_one_machine.py b/pacman/model/partitioner_splitters/splitter_one_app_one_machine.py index b6347b414..7daec388e 100644 --- a/pacman/model/partitioner_splitters/splitter_one_app_one_machine.py +++ b/pacman/model/partitioner_splitters/splitter_one_app_one_machine.py @@ -67,9 +67,10 @@ def get_in_coming_vertices(self, partition_id: str) -> List[MV]: return [self.governed_app_vertex.machine_vertex] @overrides(AbstractSplitterCommon.machine_vertices_for_recording) - def machine_vertices_for_recording(self, variable_to_record) -> List[MV]: + def machine_vertices_for_recording( + self, variable_to_record: str) -> List[MV]: return [self.governed_app_vertex.machine_vertex] @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> None: pass diff --git a/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py b/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py index 55c97ded5..92b691acb 100644 --- a/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py @@ -13,7 +13,7 @@ # limitations under the License. import logging -from typing import Optional +from typing import List, Optional from spinn_utilities.overrides import overrides from spinn_utilities.log import FormatAdapter from pacman.exceptions import PacmanConfigurationException @@ -22,6 +22,7 @@ from pacman.model.graphs.machine import MachineVertex from pacman.model.partitioner_interfaces import LegacyPartitionerAPI from pacman.model.resources import AbstractSDRAM +from pacman.utilities.utility_objs import ChipCounter from .abstract_splitter_common import AbstractSplitterCommon logger = FormatAdapter(logging.getLogger(__name__)) @@ -41,7 +42,7 @@ def __init__(self) -> None: self._sdram: Optional[AbstractSDRAM] = None @overrides(AbstractSplitterCommon.set_governed_app_vertex) - def set_governed_app_vertex(self, app_vertex): + def set_governed_app_vertex(self, app_vertex: ApplicationVertex): if not isinstance(app_vertex, LegacyPartitionerAPI): raise PacmanConfigurationException( f"{self} is not a LegacyPartitionerAPI") @@ -55,35 +56,36 @@ def set_governed_app_vertex(self, app_vertex): self.governed_app_vertex.remember_machine_vertex(self._machine_vertex) @overrides(AbstractSplitterCommon.create_machine_vertices) - def create_machine_vertices(self, chip_counter): + def create_machine_vertices(self, chip_counter: ChipCounter): assert self._sdram is not None chip_counter.add_core(self._sdram) @overrides(AbstractSplitterCommon.get_out_going_slices) - def get_out_going_slices(self): + def get_out_going_slices(self) -> List[Slice]: assert self._vertex_slice is not None return [self._vertex_slice] @overrides(AbstractSplitterCommon.get_in_coming_slices) - def get_in_coming_slices(self): + def get_in_coming_slices(self) -> List[Slice]: assert self._vertex_slice is not None return [self._vertex_slice] @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id): + def get_out_going_vertices(self, partition_id: str) -> List[MachineVertex]: assert self._machine_vertex is not None return [self._machine_vertex] @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id): + def get_in_coming_vertices(self, partition_id: str) -> List[MachineVertex]: assert self._machine_vertex is not None return [self._machine_vertex] @overrides(AbstractSplitterCommon.machine_vertices_for_recording) - def machine_vertices_for_recording(self, variable_to_record): + def machine_vertices_for_recording( + self, variable_to_record: str) -> List[MachineVertex]: assert self._machine_vertex is not None return [self._machine_vertex] @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> None: pass diff --git a/pacman/model/resources/constant_sdram.py b/pacman/model/resources/constant_sdram.py index 7fad53c33..b89cbaea2 100644 --- a/pacman/model/resources/constant_sdram.py +++ b/pacman/model/resources/constant_sdram.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Optional, TextIO from spinn_utilities.overrides import overrides from .abstract_sdram import AbstractSDRAM @@ -35,7 +36,7 @@ def __init__(self, sdram: int): self._sdram = int(sdram) @overrides(AbstractSDRAM.get_total_sdram) - def get_total_sdram(self, n_timesteps) -> int: # @UnusedVariable + def get_total_sdram(self, n_timesteps: Optional[int]) -> int: return self._sdram @property @@ -65,7 +66,7 @@ def __sub__(self, other): return other.sub_from(self) @overrides(AbstractSDRAM.sub_from) - def sub_from(self, other): + def sub_from(self, other: AbstractSDRAM) -> AbstractSDRAM: if isinstance(other, ConstantSDRAM): return ConstantSDRAM( other.fixed - self._sdram) @@ -74,5 +75,6 @@ def sub_from(self, other): return other - self @overrides(AbstractSDRAM.report) - def report(self, timesteps, indent="", preamble="", target=None): + def report(self, timesteps: Optional[int], indent: str = "", + preamble: str = "", target: Optional[TextIO] = None): print(indent, preamble, f"Constant {self._sdram} bytes", file=target) diff --git a/pacman/model/resources/multi_region_sdram.py b/pacman/model/resources/multi_region_sdram.py index 63642d62d..db2d00623 100644 --- a/pacman/model/resources/multi_region_sdram.py +++ b/pacman/model/resources/multi_region_sdram.py @@ -15,7 +15,7 @@ from enum import Enum import math import numpy -from typing import Dict, Union +from typing import Dict, Optional, TextIO, Union from typing_extensions import TypeAlias from spinn_utilities.overrides import overrides from .abstract_sdram import AbstractSDRAM @@ -132,7 +132,8 @@ def merge(self, other: MultiRegionSDRAM): self.__regions[region] = other.regions[region] @overrides(AbstractSDRAM.report) - def report(self, timesteps, indent="", preamble="", target=None): + def report(self, timesteps: Optional[int], indent: str = "", + preamble: str = "", target: Optional[TextIO] = None): super().report(timesteps, indent, preamble, target) for region in self.__regions: self.__regions[region].report( diff --git a/pacman/model/resources/variable_sdram.py b/pacman/model/resources/variable_sdram.py index cbd533810..0d020817b 100644 --- a/pacman/model/resources/variable_sdram.py +++ b/pacman/model/resources/variable_sdram.py @@ -14,7 +14,7 @@ import math import numpy -from typing import Optional, Union +from typing import Optional, TextIO, Union from spinn_utilities.overrides import overrides from pacman.exceptions import PacmanConfigurationException from .abstract_sdram import AbstractSDRAM @@ -87,7 +87,8 @@ def sub_from(self, other: AbstractSDRAM) -> 'VariableSDRAM': other.per_timestep - self._per_timestep_sdram) @overrides(AbstractSDRAM.report) - def report(self, timesteps, indent="", preamble="", target=None): + def report(self, timesteps: Optional[int], indent: str = "", + preamble: str = "", target: Optional[TextIO] = None): print(indent, preamble, f"Fixed {self._fixed_sdram} bytes " f"Per_timestep {self._per_timestep_sdram} bytes " From f5026156e6a9446851834172a0b6fe4c8f183512 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 8 Dec 2023 16:34:09 +0000 Subject: [PATCH 2/4] overrides typing --- pacman/model/graphs/common/mdslice.py | 2 +- pacman/model/graphs/common/slice.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pacman/model/graphs/common/mdslice.py b/pacman/model/graphs/common/mdslice.py index 306d87bf4..e60c6d3d9 100644 --- a/pacman/model/graphs/common/mdslice.py +++ b/pacman/model/graphs/common/mdslice.py @@ -191,7 +191,7 @@ def get_raster_indices(self, relative_indices: NDArray[numpy.integer] n_dims = len(self._atoms_shape) remainders = relative_indices cum_last_size = 1 - global_index = numpy.zeros(len(relative_indices)) + global_index = numpy.zeros(len(relative_indices), dtype=int) for n in range(n_dims): # Work out the local index in this dimension local_index_d = remainders % self._shape[n] diff --git a/pacman/model/graphs/common/slice.py b/pacman/model/graphs/common/slice.py index 288ae86f2..94d36a5b3 100644 --- a/pacman/model/graphs/common/slice.py +++ b/pacman/model/graphs/common/slice.py @@ -205,7 +205,7 @@ def from_string(cls, as_str: str) -> Slice: hi_atom = int(parts[1]) return Slice(lo_atom, hi_atom) - def get_relative_indices(self, app_vertex_indices: NDArray[numpy.interger] + def get_relative_indices(self, app_vertex_indices: NDArray[numpy.integer] ) -> NDArray[numpy.integer]: """ Convert from raster indices to slice-level indices. From 7f388dd57efa7392f8f0b2dda5e51fe040741d5f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 09:10:54 +0000 Subject: [PATCH 3/4] typing fixes --- .../partitioner_splitters/splitter_external_device.py | 2 +- .../partitioner_splitters/splitter_one_to_one_legacy.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pacman/model/partitioner_splitters/splitter_external_device.py b/pacman/model/partitioner_splitters/splitter_external_device.py index 604659502..8e5b6cdf5 100644 --- a/pacman/model/partitioner_splitters/splitter_external_device.py +++ b/pacman/model/partitioner_splitters/splitter_external_device.py @@ -163,5 +163,5 @@ def machine_vertices_for_recording( return [] @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self) -> bool: + def reset_called(self) -> None: pass diff --git a/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py b/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py index 92b691acb..10b68d060 100644 --- a/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py @@ -13,7 +13,7 @@ # limitations under the License. import logging -from typing import List, Optional +from typing import cast, List, Optional from spinn_utilities.overrides import overrides from spinn_utilities.log import FormatAdapter from pacman.exceptions import PacmanConfigurationException @@ -48,9 +48,10 @@ def set_governed_app_vertex(self, app_vertex: ApplicationVertex): f"{self} is not a LegacyPartitionerAPI") super().set_governed_app_vertex(app_vertex) self._vertex_slice = Slice(0, self.governed_app_vertex.n_atoms - 1) - self._sdram = self.governed_app_vertex.get_sdram_used_by_atoms( + lp = cast(LegacyPartitionerAPI, app_vertex) + self._sdram = lp.get_sdram_used_by_atoms( self._vertex_slice) - self._machine_vertex = self.governed_app_vertex.create_machine_vertex( + self._machine_vertex = lp.create_machine_vertex( vertex_slice=self._vertex_slice, sdram=self._sdram, label=None) self.governed_app_vertex.remember_machine_vertex(self._machine_vertex) From ffbed0df943dce8027d91ce0a42a7f9da594f6bd Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 13:01:47 +0000 Subject: [PATCH 4/4] type overrides methods --- pacman_test_objects/simple_test_vertex.py | 12 ++++++++---- .../machine_graph_tests/test_partitions.py | 2 +- .../test_zoned_routing_allocator.py | 10 +++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pacman_test_objects/simple_test_vertex.py b/pacman_test_objects/simple_test_vertex.py index 6249a5c98..9ba38e9c3 100644 --- a/pacman_test_objects/simple_test_vertex.py +++ b/pacman_test_objects/simple_test_vertex.py @@ -14,12 +14,14 @@ """ test vertex used in many unit tests """ +from typing import Optional from spinn_utilities.overrides import overrides from pacman.model.partitioner_interfaces.legacy_partitioner_api import ( LegacyPartitionerAPI) from pacman.model.graphs.application import ApplicationVertex +from pacman.model.graphs.common import Slice from pacman.model.graphs.machine import SimpleMachineVertex -from pacman.model.resources import ConstantSDRAM +from pacman.model.resources import AbstractSDRAM, ConstantSDRAM class SimpleTestVertex(ApplicationVertex, LegacyPartitionerAPI): @@ -38,7 +40,7 @@ def __init__(self, n_atoms, label="testVertex", max_atoms_per_core=256, self._fixed_sdram_value = fixed_sdram_value @overrides(LegacyPartitionerAPI.get_sdram_used_by_atoms) - def get_sdram_used_by_atoms(self, vertex_slice): + def get_sdram_used_by_atoms(self, vertex_slice: Slice) -> ConstantSDRAM: return ConstantSDRAM(self.get_sdram_usage_for_atoms(vertex_slice)) def get_sdram_usage_for_atoms(self, vertex_slice): @@ -51,10 +53,12 @@ def get_sdram_usage_for_atoms(self, vertex_slice): return self._fixed_sdram_value @overrides(LegacyPartitionerAPI.create_machine_vertex) - def create_machine_vertex(self, vertex_slice, sdram, label=None): + def create_machine_vertex( + self, vertex_slice: Slice, sdram: AbstractSDRAM, + label: Optional[str] = None) -> SimpleMachineVertex: return SimpleMachineVertex(sdram, label, self, vertex_slice) @property @overrides(ApplicationVertex.n_atoms) - def n_atoms(self): + def n_atoms(self) -> int: return self._n_atoms diff --git a/unittests/model_tests/machine_graph_tests/test_partitions.py b/unittests/model_tests/machine_graph_tests/test_partitions.py index 51c6e5b63..3daa89b51 100644 --- a/unittests/model_tests/machine_graph_tests/test_partitions.py +++ b/unittests/model_tests/machine_graph_tests/test_partitions.py @@ -31,7 +31,7 @@ class MockSupportsSDRAMEdges(SimpleMachineVertex, AbstractSupportsSDRAMEdges): @overrides(AbstractSupportsSDRAMEdges.sdram_requirement) - def sdram_requirement(self, sdram_machine_edge): + def sdram_requirement(self, sdram_machine_edge: SDRAMMachineEdge) -> int: # A mock so that the size can be different depending on prevertex return 16 + self.sdram_required.fixed diff --git a/unittests/operations_tests/routing_info_algorithms_tests/test_zoned_routing_allocator.py b/unittests/operations_tests/routing_info_algorithms_tests/test_zoned_routing_allocator.py index 63104634f..15ceb41ee 100644 --- a/unittests/operations_tests/routing_info_algorithms_tests/test_zoned_routing_allocator.py +++ b/unittests/operations_tests/routing_info_algorithms_tests/test_zoned_routing_allocator.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from typing import Optional from spinn_utilities.overrides import overrides from pacman.config_setup import unittest_setup from pacman.data import PacmanDataView @@ -59,11 +60,12 @@ def __init__(self, splitter=None, fixed_keys_by_partition=None, @property @overrides(ApplicationVertex.n_atoms) - def n_atoms(self): + def n_atoms(self) -> int: return 10 @overrides(ApplicationVertex.get_fixed_key_and_mask) - def get_fixed_key_and_mask(self, partition_id): + def get_fixed_key_and_mask( + self, partition_id: str) -> Optional[BaseKeyAndMask]: if self.__fixed_key is not None: return self.__fixed_key if self.__fixed_keys_by_partition is None: @@ -71,7 +73,9 @@ def get_fixed_key_and_mask(self, partition_id): return self.__fixed_keys_by_partition.get(partition_id) @overrides(ApplicationVertex.get_machine_fixed_key_and_mask) - def get_machine_fixed_key_and_mask(self, machine_vertex, partition_id): + def get_machine_fixed_key_and_mask( + self, machine_vertex: MachineVertex, + partition_id: str) -> Optional[BaseKeyAndMask]: if self.__fixed_machine_keys_by_partition is None: return None return self.__fixed_machine_keys_by_partition.get(