From 023e748fdca1dd51f3ee7b7a9d570d5c8bfbbc69 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 07:21:28 +0000 Subject: [PATCH 01/27] move deplicate spelling exceptions to default dict --- .pylint_dict.txt | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index 238462b96..6ccde7afc 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -17,29 +17,15 @@ Navaridas NER # Our types -AbstractEdge AbstractEdgePartition -AbstractMulticastRoutingTable -AbstractSDRAM AbstractSDRAMPartition AbstractSingleSourcePartition -AbstractVertex -ApplicationEdge -ApplicationEdgePartition -ApplicationVertex BaseKeyAndMask ChipAndCore -FPGAConnection -IPTag -IPtagResource -MachineEdge -MachineVertex MulticastEdgePartition -MulticastRoutingTable PacmanAlreadyExistsException PlacementTuple ReverseIPtagResource -RoutingTableEntry RoutingInfo RoutingTree RTEntry @@ -48,10 +34,6 @@ ValidationError # Python packages jsonschema -pacman - -# Others' types -FileIO # Python bits maxsize @@ -64,7 +46,6 @@ precompressor quicksort obj reorderable -sdram subobj vartype -xy + From a094984ee49eff4396abd096e4bd17dfdeb260d9 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 11:02:19 +0000 Subject: [PATCH 02/27] spelling fixes --- .pylint_dict.txt | 2 ++ .../fixed_route_router/fixed_route_router.py | 7 ++++--- .../operations/router_algorithms/application_router.py | 2 +- .../router_algorithms/basic_dijkstra_routing.py | 1 + pacman/operations/router_algorithms/ner_route.py | 1 + .../ordered_covering.py | 1 + .../operations/router_compressors/pair_compressor.py | 10 +++++----- .../operations/router_compressors/ranged_compressor.py | 2 +- .../zoned_routing_info_allocator.py | 4 ++-- .../algorithm_utilities/routing_algorithm_utilities.py | 6 +++--- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index 6ccde7afc..2b64ca969 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -39,6 +39,7 @@ jsonschema maxsize # Our special words +heapq mergable precompressed precompression @@ -47,5 +48,6 @@ quicksort obj reorderable subobj +unmergeable vartype diff --git a/pacman/operations/fixed_route_router/fixed_route_router.py b/pacman/operations/fixed_route_router/fixed_route_router.py index 0491424f5..e7db4d4fc 100644 --- a/pacman/operations/fixed_route_router/fixed_route_router.py +++ b/pacman/operations/fixed_route_router/fixed_route_router.py @@ -95,7 +95,7 @@ def _route_board(self, ethernet_chip: Chip): for x, y in to_route: # Check links starting with the most direct to 0,0 for link_id in [4, 3, 5, 2, 0, 1]: - # Get protential destination + # Get potential destination destination = self._machine.xy_over_link(x, y, link_id) # If it is useful if destination in routed: @@ -110,11 +110,12 @@ def _route_board(self, ethernet_chip: Chip): raise PacmanRoutingException( "Unable to do fixed point routing " f"on {ethernet_chip.ip_address}.") - to_route -= found + to_route -= fou + nd routed |= found # create final fixed route entry - # locate where to put data on ethernet chip + # locate where to put data on Ethernet chip processor_id = self.__locate_destination(ethernet_chip) # build entry and add to tables self.__add_fixed_route_entry((eth_x, eth_y), [], [processor_id]) diff --git a/pacman/operations/router_algorithms/application_router.py b/pacman/operations/router_algorithms/application_router.py index a7d6692fa..984cca167 100644 --- a/pacman/operations/router_algorithms/application_router.py +++ b/pacman/operations/router_algorithms/application_router.py @@ -288,7 +288,7 @@ def _route_source_to_target( :param dict(tuple(int,int), RoutingTree) routes: The routes made by chip (updated here) """ - # Get which vertices are targetted by the source + # Get which vertices are targeted by the source target_vertices = target.splitter.get_source_specific_in_coming_vertices( source, partition.identifier) diff --git a/pacman/operations/router_algorithms/basic_dijkstra_routing.py b/pacman/operations/router_algorithms/basic_dijkstra_routing.py index 9d8b7478c..539ce4989 100644 --- a/pacman/operations/router_algorithms/basic_dijkstra_routing.py +++ b/pacman/operations/router_algorithms/basic_dijkstra_routing.py @@ -38,6 +38,7 @@ BW_PER_ROUTE_ENTRY = 0.01 #: Maximum bandwidth of a link. MAX_BW = 250 +# pylint: disable=wrong-spelling-in-comment class _NodeInfo(object): diff --git a/pacman/operations/router_algorithms/ner_route.py b/pacman/operations/router_algorithms/ner_route.py index 32bff8a51..b48546f15 100644 --- a/pacman/operations/router_algorithms/ner_route.py +++ b/pacman/operations/router_algorithms/ner_route.py @@ -46,6 +46,7 @@ _Vec: TypeAlias = Tuple[int, int, int] _V2N: TypeAlias = Callable[[_Vec, XY], List[Tuple[int, XY]]] _Inf: Final = float("inf") +# pylint: disable=wrong-spelling-in-comment def _ner_net(src: XY, destinations: Iterable[XY], diff --git a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py index b09e5c79f..df763a6e5 100644 --- a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py +++ b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py @@ -33,6 +33,7 @@ _ROAliases: TypeAlias = Mapping[_KeyMask, FrozenSet[_KeyMask]] #: Sequence of all bit positions in a 32-bit word _all_bits = tuple(1 << i for i in range(32)) +# pylint: disable=wrong-spelling-in-comment def ordered_covering_compressor() -> MulticastRoutingTables: diff --git a/pacman/operations/router_compressors/pair_compressor.py b/pacman/operations/router_compressors/pair_compressor.py index 1d4bbd8b1..79ba82eb3 100644 --- a/pacman/operations/router_compressors/pair_compressor.py +++ b/pacman/operations/router_compressors/pair_compressor.py @@ -146,13 +146,13 @@ class _PairCompressor(AbstractCompressor): __slots__ = ( # A list of all entries which may be sorted - # of entries represented as (key, mask, defautible) + # of entries represented as (key, mask, defaultable) "_all_entries", - # flag ot use slower quicksort as it is implemented in c/ on cores + # flag to use slower quicksort as it is implemented in c/ on cores "_c_sort", - # The next index to write a merged/unmergable entry to + # The next index to write a merged/unmergeable entry to "_write_index", - # Inclusive index of last entry in the array (len in python) + # Inclusive index of last entry in the array (length in python) "_max_index", # Exclusive pointer to the end of the entries for previous buckets "_previous_index", @@ -513,7 +513,7 @@ def merge(self, entry1: RTEntry, entry2: RTEntry) -> Tuple[int, int, bool]: # Compute the new mask and key any_zeros = ~all_ones new_xs = any_ones ^ any_zeros - mask = all_selected & new_xs # Combine existing and new Xs + mask = all_selected & new_xs # Combine existing and new X's key = all_ones & mask return key, mask, entry1.defaultable and entry2.defaultable diff --git a/pacman/operations/router_compressors/ranged_compressor.py b/pacman/operations/router_compressors/ranged_compressor.py index db107d765..c7ce6d592 100644 --- a/pacman/operations/router_compressors/ranged_compressor.py +++ b/pacman/operations/router_compressors/ranged_compressor.py @@ -67,7 +67,7 @@ class RangeCompressor(object): """ # pylint: disable=attribute-defined-outside-init __slots__ = ( - # Router table to add merged rutes into + # Router table to add merged routes into "_compressed", # List of entries to be merged "_entries") diff --git a/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py b/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py index e3a770d18..49abe6c4b 100644 --- a/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py +++ b/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py @@ -258,7 +258,7 @@ def __calculate_zones(self) -> None: self.__atom_bits_per_app_part[pre, identifier] = 0 def __check_zones(self) -> None: - # See if it could fit even before considerding fixed + # See if it could fit even before considering fixed app_part_bits = allocator_bits_needed( len(self.__atom_bits_per_app_part)) if app_part_bits + self.__n_bits_atoms_and_mac > BITS_IN_KEY: @@ -365,7 +365,7 @@ def __allocate(self) -> RoutingInfo: n_bits_machine = self.__n_bits_atoms_and_mac - n_bits_atoms else: if n_bits_atoms <= self.__n_bits_atoms: - # Ok it fits use global sizes + # OK it fits use global sizes n_bits_atoms = self.__n_bits_atoms n_bits_machine = self.__n_bits_machine else: diff --git a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py index 8d816f28c..8aeafe0b8 100644 --- a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py +++ b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py @@ -60,7 +60,7 @@ def get_app_partitions() -> List[ApplicationEdgePartition]: continue internal_partitions = v.splitter.get_internal_multicast_partitions() if v not in sources and internal_partitions: - # Use dict.fromkeys to guarantee order + # guarantee order for identifier in dict.fromkeys( p.identifier for p in internal_partitions): # Add a partition with no edges to identify this as internal @@ -127,7 +127,7 @@ def avoid_dead_links(root: RoutingTree) -> RoutingTree: # new RoutingTree for the segment. new_node = RoutingTree((x, y)) # A* will not traverse anything but chips in this tree so this - # assert is meerly a sanity check that this occurred correctly. + # assert is a sanity check that this occurred correctly. assert (x, y) not in lookup, "Cycle created." lookup[(x, y)] = new_node else: @@ -291,7 +291,7 @@ def a_star(sink: XY, heuristic_source: XY, # Try all neighbouring locations. for neighbour_link in range(6): # Router.MAX_LINKS_PER_ROUTER - # Note: link identifiers arefrom the perspective of the neighbour, + # Note: link identifiers are from the perspective of the neighbour, # not the current node! neighbour = machine.xy_over_link( # Same as Router.opposite From 85147aef45d312a72d742e10482523d6d0a1530a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 10:32:00 +0000 Subject: [PATCH 03/27] spelling fixes --- pacman/model/graphs/abstract_vertex.py | 2 +- .../abstract/abstract_2d_device_vertex.py | 2 +- .../graphs/application/application_vertex.py | 2 +- pacman/model/graphs/common/chip_and_core.py | 2 +- .../splitter_fixed_legacy.py | 2 +- pacman/model/placements/placement.py | 2 +- pacman/model/resources/iptag_resource.py | 2 +- ...ticast_routing_table_by_partition_entry.py | 1 + pylint.bash | 36 +++++++++++++++++++ 9 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 pylint.bash diff --git a/pacman/model/graphs/abstract_vertex.py b/pacman/model/graphs/abstract_vertex.py index cafa5366f..d3f80f6be 100644 --- a/pacman/model/graphs/abstract_vertex.py +++ b/pacman/model/graphs/abstract_vertex.py @@ -24,7 +24,7 @@ class AbstractVertex(object): __slots__ = ( # Indicates if the Vertex has been added to a graph "_added_to_graph", - # Label for the vertex. Changable until added to graph + # Label for the vertex. Changeable until added to graph "_label", # the x, y (and p) this vertex MUST be placed on "_fixed_location") diff --git a/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py b/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py index b7cc01ab3..5f0c9d5d0 100644 --- a/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py +++ b/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py @@ -150,7 +150,7 @@ def _get_key_and_mask(self, base_key: int, index: int) -> BaseKeyAndMask: """ Get the key and mask of the given machine vertex index. - :param int base_key: The unshifted key to use + :param int base_key: The key to use (not shifted) :param int index: The machine vertex index :rtype: BaseKeyAndMask """ diff --git a/pacman/model/graphs/application/application_vertex.py b/pacman/model/graphs/application/application_vertex.py index 97de7f52f..e91fc6320 100644 --- a/pacman/model/graphs/application/application_vertex.py +++ b/pacman/model/graphs/application/application_vertex.py @@ -41,7 +41,7 @@ class ApplicationVertex(AbstractVertex, Generic[MV], metaclass=AbstractBase): """ __slots__ = ( - # List of machine verts associated with this app vertex + # List of machine vertices associated with this app vertex "_machine_vertices", # The splitter object associated with this app vertex diff --git a/pacman/model/graphs/common/chip_and_core.py b/pacman/model/graphs/common/chip_and_core.py index 56a564458..fb8de3e5e 100644 --- a/pacman/model/graphs/common/chip_and_core.py +++ b/pacman/model/graphs/common/chip_and_core.py @@ -21,7 +21,7 @@ class ChipAndCore(object): """ __slots__ = ( - # the chip coords in the SpiNNaker machine to which the machine + # the chip coordinates in the SpiNNaker machine to which the machine # vertex is placed "_x", "_y", # The processor ID on chip (x,y) that this vertex is placed on within diff --git a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py index 4968ecd00..f2544c560 100644 --- a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py @@ -80,7 +80,7 @@ def __fixed_slices(self) -> List[Slice]: @overrides(AbstractSplitterCommon.create_machine_vertices) def create_machine_vertices(self, chip_counter: ChipCounter): app_vertex = self.governed_app_vertex - # The typer needs to know the vertex implements LegacyPartitionerAPI + # The mypy needs to know the vertex implements LegacyPartitionerAPI # We know is does because we checked when setting lp = cast(LegacyPartitionerAPI, app_vertex) diff --git a/pacman/model/placements/placement.py b/pacman/model/placements/placement.py index 22124fb19..9eeb4d3b2 100644 --- a/pacman/model/placements/placement.py +++ b/pacman/model/placements/placement.py @@ -27,7 +27,7 @@ class Placement(object): # the machine vertex that is placed on the core represented "_vertex", - # the chip coords in the SpiNNaker machine to which the machine + # the chip coordinates in the SpiNNaker machine to which the machine # vertex is placed "_x", "_y", # The processor ID on chip (x,y) that this vertex is placed on within diff --git a/pacman/model/resources/iptag_resource.py b/pacman/model/resources/iptag_resource.py index d2699c8d4..72a5d2ead 100644 --- a/pacman/model/resources/iptag_resource.py +++ b/pacman/model/resources/iptag_resource.py @@ -25,7 +25,7 @@ class IPtagResource(object): # the port number that data from this tag will be sent to, or None # if the port is to be assigned elsewhere "_port", - # a boolean flag that indicates if the SDP headers are + # a Boolean flag that indicates if the SDP headers are # stripped before transmission of data "_strip_sdp", # A fixed tag ID to assign, or None if any tag is OK diff --git a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py index 4d96d3578..18ecf22c4 100644 --- a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py +++ b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py @@ -40,6 +40,7 @@ class MulticastRoutingTableByPartitionEntry(object): """ __slots__ = ( + # pylint: disable=wrong-spelling-in-comment # Entry made up of bits as follows: # | IL = 6 bits | IP = 1 bit | OL = 6 bits | OP = 18 bits | # IL = incoming link id diff --git a/pylint.bash b/pylint.bash new file mode 100644 index 000000000..7b60c2668 --- /dev/null +++ b/pylint.bash @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright (c) 2024 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +# This bash assumes that SupportScripts has been installed in parallel + +# requires the latest pylint and pyenchant +# pip install --upgrade pylint pyenchant + +# requires the spelling dicts +# sudo apt-get -o Dpkg::Use-Pty=0 install --fix-missing enchant-2 hunspell hunspell-en-gb + +dict=/tmp/dict.txt + +cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict +cat ".pylint_dict.txt" >>$dict + +# pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman +# pylint --enable=missing-function-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman + +# check docs +# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +pylint --enable=invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman + From 33c2d8dc7fc0e6f8aa9f5fac5bc2172f75e7c874 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 15:54:33 +0000 Subject: [PATCH 04/27] add docs and typing --- .../abstract/abstract_2d_device_vertex.py | 8 + .../graphs/application/application_graph.py | 6 + .../application_spinnaker_link_vertex.py | 12 ++ .../graphs/machine/machine_fpga_vertex.py | 10 ++ .../graphs/machine/machine_sdram_edge.py | 15 ++ .../machine/machine_spinnaker_link_vertex.py | 5 + .../splitter_one_to_one_legacy.py | 6 + pacman/model/resources/element_free_space.py | 3 + ...ticast_routing_table_by_partition_entry.py | 11 ++ .../multicast_routing_tables.py | 13 ++ .../uncompressed_multicast_routing_table.py | 6 + .../placer_algorithms/_spinner_api.py | 6 + .../placer_algorithms/application_placer.py | 37 ++++- .../basic_dijkstra_routing.py | 5 + .../router_compressors/pair_compressor.py | 5 + .../merged_routing_table_generator.py | 18 +++ .../algorithm_utilities/routing_tree.py | 9 ++ pacman/utilities/constants.py | 3 + pacman/utilities/json_utils.py | 137 +++++++++++++++--- pacman/utilities/utility_objs/chip_counter.py | 5 + pylint.bash | 4 +- 21 files changed, 303 insertions(+), 21 deletions(-) diff --git a/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py b/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py index 5f0c9d5d0..8669fbaec 100644 --- a/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py +++ b/pacman/model/graphs/application/abstract/abstract_2d_device_vertex.py @@ -83,6 +83,14 @@ def sub_height(self) -> int: @abstractmethod @overrides(ApplicationVertex.atoms_shape) def atoms_shape(self) -> Tuple[int, ...]: + """ + The "shape" of the atoms in the vertex i.e. how the atoms are split + between the dimensions of the vertex. By default everything is + 1-dimensional, so the value will be a 1-tuple but can be + overridden by a vertex that supports multiple dimensions. + + :rtype: tuple(int, ...) + """ raise NotImplementedError def _verify_sub_size(self) -> None: diff --git a/pacman/model/graphs/application/application_graph.py b/pacman/model/graphs/application/application_graph.py index c2502cfca..7d4ffd3f3 100644 --- a/pacman/model/graphs/application/application_graph.py +++ b/pacman/model/graphs/application/application_graph.py @@ -80,6 +80,12 @@ def vertices(self) -> Iterable[ApplicationVertex]: return self._vertex_by_label.values() def vertex_by_label(self, label: str) -> ApplicationVertex: + """ + Looks up a vertex in the graph based on the label + + :param str label: + :rtype: ApplicationVertex + """ return self._vertex_by_label[label] @property diff --git a/pacman/model/graphs/application/application_spinnaker_link_vertex.py b/pacman/model/graphs/application/application_spinnaker_link_vertex.py index ab91b7a60..56b203444 100644 --- a/pacman/model/graphs/application/application_spinnaker_link_vertex.py +++ b/pacman/model/graphs/application/application_spinnaker_link_vertex.py @@ -47,6 +47,8 @@ def __init__( The optional IP address of the board to which the device is connected e.g. in a multi-board system :param str label: The optional name of the vertex. + :param bool incoming: + :param bool outgoing: """ super().__init__(label=label) self._n_atoms = self.round_n_atoms(n_atoms) @@ -115,10 +117,20 @@ def get_outgoing_slice(self) -> Slice: @property def incoming(self) -> bool: + """ + Reports if this vertex supports incoming links + + :rtype: bool + """ return self._incoming @property def outgoing(self) -> bool: + """ + Reports if this vertex supports incoming links + + :rtype: bool + """ return self._outgoing @overrides(ApplicationVirtualVertex.get_outgoing_link_data) diff --git a/pacman/model/graphs/machine/machine_fpga_vertex.py b/pacman/model/graphs/machine/machine_fpga_vertex.py index 74be0d7fa..e2d3113a9 100644 --- a/pacman/model/graphs/machine/machine_fpga_vertex.py +++ b/pacman/model/graphs/machine/machine_fpga_vertex.py @@ -67,10 +67,20 @@ def sdram_required(self) -> ConstantSDRAM: @property def fpga_id(self) -> int: + """ + The Field Programmable Gate Arrays id provided top the init. + + :rtype: int + """ return self._fpga_id @property def fpga_link_id(self) -> int: + """ + The Field Programmable Gate Arrays link id provided to the init. + + :rtype: int + """ return self._fpga_link_id @property diff --git a/pacman/model/graphs/machine/machine_sdram_edge.py b/pacman/model/graphs/machine/machine_sdram_edge.py index 04e26ef3e..bde536315 100644 --- a/pacman/model/graphs/machine/machine_sdram_edge.py +++ b/pacman/model/graphs/machine/machine_sdram_edge.py @@ -42,14 +42,29 @@ def __init__( @property def sdram_size(self) -> int: + """ + The sdram size reported by the pre_vertex + + :rtype: int + """ return self._sdram_size @property def sdram_base_address(self) -> Optional[int]: + """ + The start address of the sdram if set + + :rtype: int or None + """ return self._sdram_base_address @sdram_base_address.setter def sdram_base_address(self, new_value: int): + """ + Sets the start address without verification + + :param int new_value: + """ self._sdram_base_address = new_value def __repr__(self): diff --git a/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py b/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py index bc73ecdda..28f62efd7 100644 --- a/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py +++ b/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py @@ -65,6 +65,11 @@ def sdram_required(self) -> ConstantSDRAM: @property def spinnaker_link_id(self) -> int: + """ + The id of the spinnaker link as passed into the init. + + :rtype: int + """ return self._spinnaker_link_id @property 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 10b68d060..be7499ef5 100644 --- a/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_one_to_one_legacy.py @@ -29,6 +29,12 @@ class SplitterOneToOneLegacy(AbstractSplitterCommon[ApplicationVertex]): + """ + A Splitter which hands an vertex with the LegacyPartitionerAPI + + The assumption is that each ApplicationVertex + will get just one Machine vertex + """ __slots__ = [ "_machine_vertex", diff --git a/pacman/model/resources/element_free_space.py b/pacman/model/resources/element_free_space.py index c2543d68c..e21bc0710 100644 --- a/pacman/model/resources/element_free_space.py +++ b/pacman/model/resources/element_free_space.py @@ -14,6 +14,9 @@ class ElementFreeSpace(object): + """ + Records the size and start address of some available space + """ __slots__ = ("_size", "_start_address") def __init__(self, start_address: int, size: int): diff --git a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py index 18ecf22c4..f2a11dfe8 100644 --- a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py +++ b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py @@ -264,10 +264,21 @@ def __repr__(self) -> str: def has_same_route( self, entry: MulticastRoutingTableByPartitionEntry) -> bool: + """ + Checks if the two Entries have the same routes after applying mask + + :param MulticastRoutingTableByPartitionEntry entry: + :rtype: bool + """ # pylint:disable=protected-access return ((self._links_and_procs & _COMPARE_MASK) == (entry._links_and_procs & _COMPARE_MASK)) @property def spinnaker_route(self) -> int: + """ + The masked routes + + :rtype: int + """ return self._links_and_procs & _SPINNAKER_ROUTE_MASK diff --git a/pacman/model/routing_tables/multicast_routing_tables.py b/pacman/model/routing_tables/multicast_routing_tables.py index cff5b37e5..db38424df 100644 --- a/pacman/model/routing_tables/multicast_routing_tables.py +++ b/pacman/model/routing_tables/multicast_routing_tables.py @@ -134,6 +134,12 @@ def __iter__(self) -> Iterator[AbstractMulticastRoutingTable]: def to_json(router_table: MulticastRoutingTables) -> JsonObjectArray: + """ + Converts RoutingTables to json + + :param MulticastRoutingTables router_table: + :rtype: list(dict(str, object)) + """ return [ { "x": routing_table.x, @@ -151,6 +157,13 @@ def to_json(router_table: MulticastRoutingTables) -> JsonObjectArray: def from_json(j_router: Union[str, JsonObjectArray]) -> MulticastRoutingTables: + """ + Creates Routing Tables based on json + + :param j_router: + :type: str or list + :rtype: MulticastRoutingTables + """ if isinstance(j_router, str): if j_router.endswith(".gz"): with gzip.open(j_router) as j_file: diff --git a/pacman/model/routing_tables/uncompressed_multicast_routing_table.py b/pacman/model/routing_tables/uncompressed_multicast_routing_table.py index 4cb06f52d..e9973c628 100644 --- a/pacman/model/routing_tables/uncompressed_multicast_routing_table.py +++ b/pacman/model/routing_tables/uncompressed_multicast_routing_table.py @@ -152,6 +152,12 @@ def _from_csv_file( def from_csv(file_name: str) -> UnCompressedMulticastRoutingTable: + """ + Reads a comma separated file into Routing Tables + + :param str file_name: + :rtype: UnCompressedMulticastRoutingTable: + """ if file_name.endswith(".gz"): with gzip.open(file_name, mode="rt", newline='') as csvfile: return _from_csv_file(csvfile) diff --git a/pacman/operations/placer_algorithms/_spinner_api.py b/pacman/operations/placer_algorithms/_spinner_api.py index b398e8823..a07be68ae 100644 --- a/pacman/operations/placer_algorithms/_spinner_api.py +++ b/pacman/operations/placer_algorithms/_spinner_api.py @@ -40,6 +40,12 @@ class Spinner: @staticmethod def import_api() -> 'Spinner': + """ + Loads the required imports and returns a Spinner + + :rtype: Spinner + :raises ImportError: if on Windows + """ # spinner as graphical library so # pylint: disable=import-error diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index 0212634ba..058cb8ec5 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -477,6 +477,9 @@ def save_chips(self, chips: Iterable[Chip]): self.__saved_chips.update(chips) def restore_chips(self) -> None: + """ + Moves all the saved chips form used to restored + """ for chip in self.__saved_chips: self.__used_chips.remove(chip) self.__restored_chips.add(chip) @@ -540,6 +543,12 @@ class _ChipWithSpace(object): def __init__( self, chip: Chip, used_processors: Set[int], used_sdram: int): + """ + + :param Chip chip: + :param set(int) used_processors: + :param int used_sdram: + """ self.chip = chip self.cores = set(p.processor_id for p in chip.processors if not p.is_monitor) @@ -548,19 +557,45 @@ def __init__( @property def x(self) -> int: - return self.chip.x + """ + The x value of the Chip passed in at init time + + :rtype: int + """ @property def y(self) -> int: + """ + The y value of the Chip passed in at init time + + :rtype: int + """ return self.chip.y def is_space(self, n_cores: int, sdram: int) -> bool: + """ + CHecks if there is space based on both cores and sdram + + :param int n_cores: + :param int sdram: + :rtype: bool + """ return len(self.cores) >= n_cores and self.sdram >= sdram def use_sdram(self, sdram: int): + """ + Reduces available sdram by this amount + + :param int sdram: + """ self.sdram -= sdram def use_next_core(self) -> int: + """ + Pops a core value + + :rtype: int + """ core = next(iter(self.cores)) self.cores.remove(core) return core diff --git a/pacman/operations/router_algorithms/basic_dijkstra_routing.py b/pacman/operations/router_algorithms/basic_dijkstra_routing.py index 539ce4989..e34fc62f6 100644 --- a/pacman/operations/router_algorithms/basic_dijkstra_routing.py +++ b/pacman/operations/router_algorithms/basic_dijkstra_routing.py @@ -54,6 +54,11 @@ def __init__(self) -> None: @property def neighweights(self) -> Iterable[Tuple[Optional[Link], float]]: + """ + Zip of neighbours and their weights + + :rtype: iterable(link or None, float) + """ return zip(self.neighbours, self.weights) diff --git a/pacman/operations/router_compressors/pair_compressor.py b/pacman/operations/router_compressors/pair_compressor.py index 79ba82eb3..1e03eeb65 100644 --- a/pacman/operations/router_compressors/pair_compressor.py +++ b/pacman/operations/router_compressors/pair_compressor.py @@ -519,4 +519,9 @@ def merge(self, entry1: RTEntry, entry2: RTEntry) -> Tuple[int, int, bool]: @property def ordered(self) -> bool: + """ + The ordered value passed into the init + + :rtype: bool + """ return self._ordered diff --git a/pacman/operations/routing_table_generators/merged_routing_table_generator.py b/pacman/operations/routing_table_generators/merged_routing_table_generator.py index 35f804568..d7aca7b44 100644 --- a/pacman/operations/routing_table_generators/merged_routing_table_generator.py +++ b/pacman/operations/routing_table_generators/merged_routing_table_generator.py @@ -180,7 +180,14 @@ def __merged_keys_and_masks( class _IteratorWithNext(Generic[E]): + """ + An iterator wrapper which allows peek + """ + def __init__(self, iterable: Iterable[E]): + """ + :param iterable: iterable to be wrapped + """ self.__iterator = iter(iterable) try: self.__next: Optional[E] = next(self.__iterator) @@ -190,13 +197,24 @@ def __init__(self, iterable: Iterable[E]): self.__has_next = False def peek(self) -> Optional[E]: + """ + The Element if any that would be returned by a pop call + """ return self.__next @property def has_next(self) -> bool: + """ + True if there is another element for Peek or Pop to return + """ return self.__has_next def pop(self) -> E: + """ + The next element available. + + :raises: StopIteration if there is not more element available + """ if not self.__has_next: raise StopIteration nxt = self.__next diff --git a/pacman/utilities/algorithm_utilities/routing_tree.py b/pacman/utilities/algorithm_utilities/routing_tree.py index 9392ff68c..debef53fc 100644 --- a/pacman/utilities/algorithm_utilities/routing_tree.py +++ b/pacman/utilities/algorithm_utilities/routing_tree.py @@ -62,6 +62,11 @@ def __init__(self, chip: XY, label: Optional[str] = None): @property def label(self) -> Optional[str]: + """ + The label value provided to the init (if applicable). + + :rtype: str or None + """ return self._label @property @@ -121,6 +126,10 @@ def remove_child( @property def is_leaf(self) -> bool: + """ + Detect if this is a leaf node. IE has no children. + :return: + """ return not self._children def __iter__(self) -> Iterator[Union[RoutingTree, MachineVertex]]: diff --git a/pacman/utilities/constants.py b/pacman/utilities/constants.py index 445acfd82..bef5ec416 100644 --- a/pacman/utilities/constants.py +++ b/pacman/utilities/constants.py @@ -27,6 +27,9 @@ class EDGES(Enum): + """ + The 6 directions links can go. + """ EAST = 0 NORTH_EAST = 1 NORTH = 2 diff --git a/pacman/utilities/json_utils.py b/pacman/utilities/json_utils.py index e49bfae18..84935f393 100644 --- a/pacman/utilities/json_utils.py +++ b/pacman/utilities/json_utils.py @@ -17,14 +17,21 @@ import json import gzip +from typing import List, Optional, Union + +from spinn_utilities.typing.json import JsonArray, JsonObject + from pacman.data import PacmanDataView +from pacman.model.graphs.application import ( + ApplicationGraph, ApplicationVertex) +from pacman.model.graphs.machine import MachineVertex, SimpleMachineVertex +from pacman.model.placements.placement import Placement from pacman.model.resources import ( IPtagResource, ReverseIPtagResource, VariableSDRAM) -from pacman.model.graphs.machine import SimpleMachineVertex -from pacman.model.placements.placement import Placement +from pacman.model.routing_info import BaseKeyAndMask -def json_to_object(json_object): +def json_to_object(json_object: Union[str, JsonObject]) -> JsonObject: """ Makes sure this is a JSON object reading in a file if required @@ -43,7 +50,13 @@ def json_to_object(json_object): return json_object -def key_mask_to_json(key_mask): +def key_mask_to_json(key_mask: BaseKeyAndMask) -> JsonObject: + """ + Converts a BaseKeyAndMask into json + + :param BaseKeyAndMask key_mask: + :rtype: dict(str, object) + """ try: json_object = dict() json_object["key"] = key_mask.key @@ -53,7 +66,13 @@ def key_mask_to_json(key_mask): return json_object -def iptag_resource_to_json(iptag): +def iptag_resource_to_json(iptag: IPtagResource) -> JsonObject: + """ + Converts an iptag to json + + :param IPtagResource iptag: + :rtype: dict(str, object) + """ json_dict = dict() try: json_dict["ip_address"] = iptag.ip_address @@ -68,7 +87,13 @@ def iptag_resource_to_json(iptag): return json_dict -def iptag_resource_from_json(json_dict): +def iptag_resource_from_json(json_dict: JsonObject) -> IPtagResource: + """ + Creates an iptag from json + + :param dict(str, object) json_dict: + :rtype: IPtagResource + """ port = json_dict.get("port") tag = json_dict.get("tag") return IPtagResource( @@ -76,21 +101,39 @@ def iptag_resource_from_json(json_dict): json_dict["traffic_identifier"]) -def iptag_resources_to_json(iptags): +def iptag_resources_to_json(iptags: List[IPtagResource]) -> JsonArray: + """ + Converts a list of iptags to json. + + :param list(IPtagResource) iptags: + :rtype: list + """ json_list = [] for iptag in iptags: json_list.append(iptag_resource_to_json(iptag)) return json_list -def iptag_resources_from_json(json_list): +def iptag_resources_from_json(json_list: JsonArray) -> List[IPtagResource]: + """ + Creates a list of iptags from json. + + :param list(dict(str, object)) json_list: + :rtype: list(IPtagResource) + """ iptags = [] for json_dict in json_list: iptags.append(iptag_resource_from_json(json_dict)) return iptags -def reverse_iptag_to_json(iptag): +def reverse_iptag_to_json(iptag: ReverseIPtagResource) -> JsonObject: + """ + Converts a reverse iptag to json + + :param ReverseIPtagResource iptag: + :rtype: dict(object) + """ json_dict = dict() try: if iptag.port is not None: @@ -103,28 +146,53 @@ def reverse_iptag_to_json(iptag): return json_dict -def reverse_iptag_from_json(json_dict): +def reverse_iptag_from_json(json_dict: JsonObject) -> ReverseIPtagResource: + """ + Creates a ReverseIPtagResource based on json + + :param dict(str, object) json_dict: + :rtype: ReverseIPtagResource + """ port = json_dict.get("port") sdp_port = json_dict["sdp_port"] tag = json_dict.get("tag") return ReverseIPtagResource(port, sdp_port, tag) -def reverse_iptags_to_json(iptags): +def reverse_iptags_to_json(iptags: List[ReverseIPtagResource]) -> JsonArray: + """ + Converts a list of reverse iptags to json + + :param list(ReverseIPtagResource) iptags: + :rtype: list + """ json_list = [] for iptag in iptags: json_list.append(reverse_iptag_to_json(iptag)) return json_list -def reverse_iptags_from_json(json_list): +def reverse_iptags_from_json( + json_list: JsonArray) -> List[ReverseIPtagResource]: + """ + Creates a list of ReverseIPtagResource from json + + :param list json_list: + :type: list(ReverseIPtagResource) + """ iptags = [] for json_dict in json_list: iptags.append(reverse_iptag_from_json(json_dict)) return iptags -def vertex_to_json(vertex): +def vertex_to_json(vertex: MachineVertex) -> JsonObject: + """ + Converts a Machine Vertex to json. + + :param MachineVertex vertex: + :rtype: dict(str, object) + """ json_dict = dict() try: json_dict["class"] = vertex.__class__.__name__ @@ -140,7 +208,13 @@ def vertex_to_json(vertex): return json_dict -def vertex_from_json(json_dict): +def vertex_from_json(json_dict: JsonObject) -> SimpleMachineVertex: + """ + Creates a simple Vertex based on the json + + :param dict(str, object) json_dict: + :rtype: SimpleMachineVertex + """ sdram = VariableSDRAM( json_dict["fixed_sdram"], json_dict["per_timestep_sdram"]) iptags = iptag_resources_from_json(json_dict["iptags"]) @@ -150,13 +224,28 @@ def vertex_from_json(json_dict): reverse_iptags=reverse_iptags) -def vertex_lookup(label, graph=None): +def vertex_lookup( + label, graph: Optional[ApplicationGraph] = None) -> ApplicationVertex: + """ + Looks up the vertex in the graph or create a simple vertex if no graph + + :param str label: + :param graph: ApplicationGraph if applicable + :type graph: ApplicationGraph or None + :rtype: ApplicationVertex + """ if graph: return graph.vertex_by_label(label) return SimpleMachineVertex(None, label) -def placement_to_json(placement): +def placement_to_json(placement: Placement) -> JsonObject: + """ + Converts a Placement to json + + :param Placement placement: + :rtype: dict(str, object) + """ json_dict = dict() try: json_dict["vertex_label"] = placement.vertex.label @@ -168,14 +257,26 @@ def placement_to_json(placement): return json_dict -def placements_to_json(): +def placements_to_json() -> JsonArray: + """ + Gets a json description of the placements (held in DataView) + """ json_list = [] for placement in PacmanDataView.iterate_placemements(): json_list.append(placement_to_json(placement)) return json_list -def placement_from_json(json_dict, graph=None): +def placement_from_json(json_dict: JsonObject, + graph: Optional[ApplicationGraph] = None) -> Placement: + """ + Gets a Placement based on the json. + + :param dict(str, object) json_dict: + :param graph: Application Graph (if used) + :type graph: ApplicationGraph or None + :rtype: Placement + """ vertex = vertex_lookup(json_dict["vertex_label"], graph) return Placement( vertex, int(json_dict["x"]), int(json_dict["y"]), int(json_dict["p"])) diff --git a/pacman/utilities/utility_objs/chip_counter.py b/pacman/utilities/utility_objs/chip_counter.py index b7724dfbd..91b2e104e 100644 --- a/pacman/utilities/utility_objs/chip_counter.py +++ b/pacman/utilities/utility_objs/chip_counter.py @@ -50,6 +50,11 @@ def __init__( self.__n_chips = 0 def add_core(self, resources: AbstractSDRAM): + """ + Adds a core (or if needed a Chip) to the count + + :param AbstractSDRAM resources: + """ sdram = resources.get_total_sdram( PacmanDataView.get_plan_n_timestep()) if self.__cores_free == 0 or self.__sdram_free < sdram: diff --git a/pylint.bash b/pylint.bash index 7b60c2668..386dc3592 100644 --- a/pylint.bash +++ b/pylint.bash @@ -31,6 +31,6 @@ cat ".pylint_dict.txt" >>$dict # pylint --enable=missing-function-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman # check docs -# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman -pylint --enable=invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +# pylint --enable=invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman From 2647021537833714f2225ea476474f325987551a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 16:01:56 +0000 Subject: [PATCH 05/27] fix spacing error --- pacman/operations/fixed_route_router/fixed_route_router.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pacman/operations/fixed_route_router/fixed_route_router.py b/pacman/operations/fixed_route_router/fixed_route_router.py index e7db4d4fc..cb39899cf 100644 --- a/pacman/operations/fixed_route_router/fixed_route_router.py +++ b/pacman/operations/fixed_route_router/fixed_route_router.py @@ -110,8 +110,7 @@ def _route_board(self, ethernet_chip: Chip): raise PacmanRoutingException( "Unable to do fixed point routing " f"on {ethernet_chip.ip_address}.") - to_route -= fou - nd + to_route -= found routed |= found # create final fixed route entry From fef038d62cdc668efef73f67c7598f0e03a0fced Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 16:07:05 +0000 Subject: [PATCH 06/27] group imports --- .../graphs/machine/constant_sdram_machine_partition.py | 7 +++++-- pacman/model/routing_info/vertex_routing_info.py | 7 +++++-- .../routing_tables/abstract_multicast_routing_table.py | 3 ++- .../uncompressed_multicast_routing_table.py | 3 ++- .../partition_algorithms/splitter_partitioner.py | 2 +- pylint.bash | 8 +++++--- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pacman/model/graphs/machine/constant_sdram_machine_partition.py b/pacman/model/graphs/machine/constant_sdram_machine_partition.py index fa0481888..553b99437 100644 --- a/pacman/model/graphs/machine/constant_sdram_machine_partition.py +++ b/pacman/model/graphs/machine/constant_sdram_machine_partition.py @@ -12,13 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. from typing import Generic, Optional, Type, TypeVar, cast -from pacman.model.graphs.machine import AbstractSDRAMPartition -from pacman.model.graphs import AbstractSingleSourcePartition + from spinn_utilities.overrides import overrides + from pacman.exceptions import ( PacmanConfigurationException, PartitionMissingEdgesException, SDRAMEdgeSizeException) +from pacman.model.graphs.machine import AbstractSDRAMPartition +from pacman.model.graphs import AbstractSingleSourcePartition from pacman.model.graphs.machine import SDRAMMachineEdge + from .machine_vertex import MachineVertex #: :meta private: diff --git a/pacman/model/routing_info/vertex_routing_info.py b/pacman/model/routing_info/vertex_routing_info.py index 2c3bdfcbe..cfd25171f 100644 --- a/pacman/model/routing_info/vertex_routing_info.py +++ b/pacman/model/routing_info/vertex_routing_info.py @@ -13,12 +13,15 @@ # limitations under the License. from typing import Optional, Union import numpy -from pacman.exceptions import PacmanConfigurationException + from spinn_utilities.abstract_base import abstractmethod, AbstractBase -from .base_key_and_mask import BaseKeyAndMask + +from pacman.exceptions import PacmanConfigurationException from pacman.model.graphs.application import ApplicationVertex from pacman.model.graphs.machine import MachineVertex +from .base_key_and_mask import BaseKeyAndMask + class VertexRoutingInfo(object, metaclass=AbstractBase): """ diff --git a/pacman/model/routing_tables/abstract_multicast_routing_table.py b/pacman/model/routing_tables/abstract_multicast_routing_table.py index 2658ae61f..4708a0f53 100644 --- a/pacman/model/routing_tables/abstract_multicast_routing_table.py +++ b/pacman/model/routing_tables/abstract_multicast_routing_table.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. from typing import Any, Collection + from spinn_utilities.abstract_base import AbstractBase, abstractmethod from spinn_machine import Chip -from pacman.data.pacman_data_view import PacmanDataView from spinn_machine.multicast_routing_entry import MulticastRoutingEntry +from pacman.data.pacman_data_view import PacmanDataView class AbstractMulticastRoutingTable(object, metaclass=AbstractBase): diff --git a/pacman/model/routing_tables/uncompressed_multicast_routing_table.py b/pacman/model/routing_tables/uncompressed_multicast_routing_table.py index e9973c628..7f36d23c9 100644 --- a/pacman/model/routing_tables/uncompressed_multicast_routing_table.py +++ b/pacman/model/routing_tables/uncompressed_multicast_routing_table.py @@ -16,11 +16,12 @@ import gzip import logging from typing import Any, Collection, Dict, Iterable + from spinn_utilities.log import FormatAdapter +from spinn_utilities.overrides import overrides from spinn_machine import MulticastRoutingEntry from pacman.exceptions import PacmanAlreadyExistsException from pacman.model.routing_tables import AbstractMulticastRoutingTable -from spinn_utilities.overrides import overrides logger = FormatAdapter(logging.getLogger(__name__)) diff --git a/pacman/operations/partition_algorithms/splitter_partitioner.py b/pacman/operations/partition_algorithms/splitter_partitioner.py index 76f88bb01..566b3bde0 100644 --- a/pacman/operations/partition_algorithms/splitter_partitioner.py +++ b/pacman/operations/partition_algorithms/splitter_partitioner.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from pacman.data import PacmanDataView from spinn_utilities.progress_bar import ProgressBar +from pacman.data import PacmanDataView from pacman.utilities.utility_objs.chip_counter import ChipCounter diff --git a/pylint.bash b/pylint.bash index 386dc3592..486854516 100644 --- a/pylint.bash +++ b/pylint.bash @@ -27,10 +27,12 @@ dict=/tmp/dict.txt cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict +# check all # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman -# pylint --enable=missing-function-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman + +# check one test +pylint --enable=ungrouped-imports --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman # check docs -pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman -# pylint --enable=invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman From e9ed7544c8c23a7a50fbc5fa178620689d34e1e5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 16:27:08 +0000 Subject: [PATCH 07/27] standardize import order --- .../graphs/application/application_2d_fpga_vertex.py | 7 +++++-- .../application/application_2d_spinnaker_link_vertex.py | 5 ++++- pacman/model/graphs/application/application_graph.py | 8 +++++--- pacman/model/graphs/application/application_vertex.py | 5 ++++- .../model/graphs/machine/machine_spinnaker_link_vertex.py | 5 ++++- pacman/model/graphs/machine/simple_machine_vertex.py | 5 ++++- .../partitioner_splitters/splitter_external_device.py | 8 +++++++- .../model/partitioner_splitters/splitter_fixed_legacy.py | 7 ++++++- pacman/model/placements/placements.py | 5 ++++- pacman/model/resources/multi_region_sdram.py | 6 +++++- pacman/model/resources/variable_sdram.py | 4 +++- pacman/model/routing_info/machine_vertex_routing_info.py | 2 +- .../routing_tables/compressed_multicast_routing_table.py | 2 +- pacman/model/routing_tables/multicast_routing_tables.py | 5 ++++- pacman/operations/router_algorithms/ner_route.py | 5 ++++- .../ordered_covering.py | 8 +++++++- .../algorithm_utilities/routing_algorithm_utilities.py | 6 +++++- pacman/utilities/file_format_schemas/__init__.py | 4 +++- pylint.bash | 2 +- 19 files changed, 77 insertions(+), 22 deletions(-) diff --git a/pacman/model/graphs/application/application_2d_fpga_vertex.py b/pacman/model/graphs/application/application_2d_fpga_vertex.py index 75e7ebb1e..c16360845 100644 --- a/pacman/model/graphs/application/application_2d_fpga_vertex.py +++ b/pacman/model/graphs/application/application_2d_fpga_vertex.py @@ -13,12 +13,15 @@ # limitations under the License. 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 -from .fpga_connection import FPGAConnection from pacman.model.graphs.common import Slice +from .application_fpga_vertex import ApplicationFPGAVertex +from .fpga_connection import FPGAConnection + class Application2DFPGAVertex(ApplicationFPGAVertex, Abstract2DDeviceVertex): """ 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 a1643fecc..07932e76a 100644 --- a/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py +++ b/pacman/model/graphs/application/application_2d_spinnaker_link_vertex.py @@ -13,11 +13,14 @@ # limitations under the License. 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 from pacman.model.graphs.common import Slice +from .application_spinnaker_link_vertex import ApplicationSpiNNakerLinkVertex + class Application2DSpiNNakerLinkVertex( ApplicationSpiNNakerLinkVertex, Abstract2DDeviceVertex): diff --git a/pacman/model/graphs/application/application_graph.py b/pacman/model/graphs/application/application_graph.py index 7d4ffd3f3..32c4f4dc5 100644 --- a/pacman/model/graphs/application/application_graph.py +++ b/pacman/model/graphs/application/application_graph.py @@ -14,13 +14,15 @@ from __future__ import annotations from collections import defaultdict from typing import Dict, Iterable, Optional, Sequence, cast -from .application_edge import ApplicationEdge -from .application_vertex import ApplicationVertex -from .application_edge_partition import ApplicationEdgePartition + from spinn_utilities.ordered_set import OrderedSet from pacman.exceptions import ( PacmanAlreadyExistsException, PacmanInvalidParameterException) +from .application_edge import ApplicationEdge +from .application_edge_partition import ApplicationEdgePartition +from .application_vertex import ApplicationVertex + class ApplicationGraph(object): """ diff --git a/pacman/model/graphs/application/application_vertex.py b/pacman/model/graphs/application/application_vertex.py index e91fc6320..e74277e18 100644 --- a/pacman/model/graphs/application/application_vertex.py +++ b/pacman/model/graphs/application/application_vertex.py @@ -13,13 +13,16 @@ # limitations under the License. from __future__ import annotations import logging -import numpy from typing import ( Collection, Generic, Optional, Tuple, TypeVar, Union, cast, TYPE_CHECKING) + +import numpy from typing_extensions import Self + from spinn_utilities.abstract_base import AbstractBase, abstractmethod from spinn_utilities.ordered_set import OrderedSet from spinn_utilities.log import FormatAdapter + from pacman.exceptions import ( PacmanConfigurationException, PacmanInvalidParameterException) from pacman.model.graphs import AbstractVertex diff --git a/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py b/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py index 28f62efd7..f09e776e5 100644 --- a/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py +++ b/pacman/model/graphs/machine/machine_spinnaker_link_vertex.py @@ -13,10 +13,13 @@ # limitations under the License. from __future__ import annotations from typing import List, Optional, TYPE_CHECKING + from spinn_utilities.overrides import overrides + +from pacman.model.graphs import AbstractVirtual from pacman.model.resources import ConstantSDRAM from .machine_vertex import MachineVertex -from pacman.model.graphs import AbstractVirtual + if TYPE_CHECKING: from spinn_utilities.typing.coords import XY from spinn_machine import Machine diff --git a/pacman/model/graphs/machine/simple_machine_vertex.py b/pacman/model/graphs/machine/simple_machine_vertex.py index 8e30e2969..04c2efc74 100644 --- a/pacman/model/graphs/machine/simple_machine_vertex.py +++ b/pacman/model/graphs/machine/simple_machine_vertex.py @@ -13,12 +13,15 @@ # 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 +from .machine_vertex import MachineVertex + class SimpleMachineVertex(MachineVertex): """ diff --git a/pacman/model/partitioner_splitters/splitter_external_device.py b/pacman/model/partitioner_splitters/splitter_external_device.py index 8e5b6cdf5..72f029eaa 100644 --- a/pacman/model/partitioner_splitters/splitter_external_device.py +++ b/pacman/model/partitioner_splitters/splitter_external_device.py @@ -11,20 +11,26 @@ # 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 List, Optional, Union + from typing_extensions import TypeAlias + from spinn_utilities.overrides import overrides + from pacman.model.graphs.application import ( ApplicationFPGAVertex, ApplicationSpiNNakerLinkVertex) from pacman.model.graphs.machine import ( MachineFPGAVertex, MachineSpiNNakerLinkVertex) from pacman.exceptions import ( PacmanConfigurationException, PacmanNotExistException) -from .abstract_splitter_common import AbstractSplitterCommon from pacman.model.graphs.application import FPGAConnection from pacman.utilities.utility_objs import ChipCounter from pacman.model.graphs.machine import MachineVertex from pacman.model.graphs.common import Slice + +from .abstract_splitter_common import AbstractSplitterCommon + _Allowed: TypeAlias = Union[ ApplicationFPGAVertex, ApplicationSpiNNakerLinkVertex] diff --git a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py index f2544c560..aff347e40 100644 --- a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py @@ -11,19 +11,24 @@ # 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. + import logging from typing import cast, Generic, List, Optional + from spinn_utilities.overrides import overrides from spinn_utilities.log import FormatAdapter + from pacman.exceptions import PacmanConfigurationException from pacman.model.partitioner_interfaces import LegacyPartitionerAPI from pacman.utilities.algorithm_utilities.partition_algorithm_utilities import\ get_multidimensional_slices -from .abstract_splitter_common import AbstractSplitterCommon, V from pacman.model.graphs.machine import MachineVertex from pacman.model.graphs.common import Slice from pacman.utilities.utility_objs import ChipCounter +from .abstract_splitter_common import AbstractSplitterCommon, V + + logger = FormatAdapter(logging.getLogger(__name__)) diff --git a/pacman/model/placements/placements.py b/pacman/model/placements/placements.py index f8fea3b91..969267411 100644 --- a/pacman/model/placements/placements.py +++ b/pacman/model/placements/placements.py @@ -14,13 +14,16 @@ from collections import defaultdict from typing import Dict, Iterable, Iterator + from spinn_utilities.typing.coords import XY + from pacman.exceptions import ( PacmanAlreadyPlacedError, PacmanNotPlacedError, PacmanProcessorAlreadyOccupiedError, PacmanProcessorNotOccupiedError) -from .placement import Placement from pacman.model.graphs.machine.machine_vertex import MachineVertex +from .placement import Placement + class Placements(object): """ diff --git a/pacman/model/resources/multi_region_sdram.py b/pacman/model/resources/multi_region_sdram.py index db2d00623..4c546fcc7 100644 --- a/pacman/model/resources/multi_region_sdram.py +++ b/pacman/model/resources/multi_region_sdram.py @@ -14,13 +14,17 @@ from __future__ import annotations from enum import Enum import math -import numpy from typing import Dict, Optional, TextIO, Union + +import numpy from typing_extensions import TypeAlias + from spinn_utilities.overrides import overrides + from .abstract_sdram import AbstractSDRAM from .constant_sdram import ConstantSDRAM from .variable_sdram import VariableSDRAM + _RegionKey: TypeAlias = Union[int, str, Enum] _Value: TypeAlias = Union[int, float, numpy.integer, numpy.floating] diff --git a/pacman/model/resources/variable_sdram.py b/pacman/model/resources/variable_sdram.py index 0d020817b..0dc1419b3 100644 --- a/pacman/model/resources/variable_sdram.py +++ b/pacman/model/resources/variable_sdram.py @@ -13,8 +13,10 @@ # limitations under the License. import math -import numpy from typing import Optional, TextIO, Union + +import numpy + from spinn_utilities.overrides import overrides from pacman.exceptions import PacmanConfigurationException from .abstract_sdram import AbstractSDRAM diff --git a/pacman/model/routing_info/machine_vertex_routing_info.py b/pacman/model/routing_info/machine_vertex_routing_info.py index 1baf38b4e..1be2d32b1 100644 --- a/pacman/model/routing_info/machine_vertex_routing_info.py +++ b/pacman/model/routing_info/machine_vertex_routing_info.py @@ -13,8 +13,8 @@ # limitations under the License. from __future__ import annotations from typing import TYPE_CHECKING -from .vertex_routing_info import VertexRoutingInfo from spinn_utilities.overrides import overrides +from .vertex_routing_info import VertexRoutingInfo if TYPE_CHECKING: from .base_key_and_mask import BaseKeyAndMask from pacman.model.graphs.machine import MachineVertex diff --git a/pacman/model/routing_tables/compressed_multicast_routing_table.py b/pacman/model/routing_tables/compressed_multicast_routing_table.py index 37d312e05..8660478c7 100644 --- a/pacman/model/routing_tables/compressed_multicast_routing_table.py +++ b/pacman/model/routing_tables/compressed_multicast_routing_table.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. from typing import Any, Collection, Iterable, List -from pacman.model.routing_tables import AbstractMulticastRoutingTable from spinn_utilities.overrides import overrides from spinn_machine.multicast_routing_entry import MulticastRoutingEntry +from pacman.model.routing_tables import AbstractMulticastRoutingTable class CompressedMulticastRoutingTable(AbstractMulticastRoutingTable): diff --git a/pacman/model/routing_tables/multicast_routing_tables.py b/pacman/model/routing_tables/multicast_routing_tables.py index db38424df..6a17bd20b 100644 --- a/pacman/model/routing_tables/multicast_routing_tables.py +++ b/pacman/model/routing_tables/multicast_routing_tables.py @@ -16,13 +16,16 @@ import gzip from typing import ( Collection, Dict, Iterable, Iterator, Optional, Union, cast) + from spinn_utilities.typing.coords import XY from spinn_utilities.typing.json import JsonObjectArray +from spinn_machine import MulticastRoutingEntry + from pacman.exceptions import PacmanAlreadyExistsException + from .abstract_multicast_routing_table import AbstractMulticastRoutingTable from .uncompressed_multicast_routing_table import ( UnCompressedMulticastRoutingTable) -from spinn_machine import MulticastRoutingEntry class MulticastRoutingTables(object): diff --git a/pacman/operations/router_algorithms/ner_route.py b/pacman/operations/router_algorithms/ner_route.py index b48546f15..cb4d8dd4e 100644 --- a/pacman/operations/router_algorithms/ner_route.py +++ b/pacman/operations/router_algorithms/ner_route.py @@ -25,14 +25,16 @@ https://github.com/project-rig/rig/blob/master/rig/place_and_route/route/utils.py """ +from collections import defaultdict import functools from typing import Callable, Dict, Final, Iterable, List, Tuple + from typing_extensions import TypeAlias -from collections import defaultdict from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.ordered_set import OrderedSet from spinn_utilities.typing.coords import XY + from pacman.data import PacmanDataView from pacman.model.routing_table_by_partition import ( MulticastRoutingTableByPartition) @@ -43,6 +45,7 @@ from pacman.model.graphs.application import ApplicationVertex from pacman.utilities.algorithm_utilities.routing_tree import RoutingTree from pacman.model.graphs.machine import MachineVertex + _Vec: TypeAlias = Tuple[int, int, int] _V2N: TypeAlias = Callable[[_Vec, XY], List[Tuple[int, XY]]] _Inf: Final = float("inf") diff --git a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py index df763a6e5..850eb9aaf 100644 --- a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py +++ b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py @@ -15,16 +15,22 @@ from typing import ( Collection, Dict, FrozenSet, Iterable, List, Mapping, Optional, Set, Tuple, Union, cast) + + from typing_extensions import TypeAlias + from spinn_utilities.config_holder import get_config_bool from spinn_utilities.timer import Timer + from pacman.exceptions import MinimisationFailedError from pacman.utilities.constants import FULL_MASK from pacman.model.routing_tables import UnCompressedMulticastRoutingTable from pacman.operations.router_compressors import (AbstractCompressor, RTEntry) -from .utils import intersect, remove_default_routes from pacman.model.routing_tables import MulticastRoutingTables from pacman.data.pacman_data_view import PacmanDataView + +from .utils import intersect, remove_default_routes + #: A key,mask pair _KeyMask: TypeAlias = Tuple[int, int] #: A mapping from a key,mask pair to the things it aliases diff --git a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py index 8aeafe0b8..fab15184b 100644 --- a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py +++ b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py @@ -11,13 +11,15 @@ # 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 collections import deque, defaultdict import heapq import itertools from typing import Deque, Dict, Iterable, List, Optional, Set, Tuple + from spinn_utilities.typing.coords import XY -from .routing_tree import RoutingTree from spinn_machine import Machine, Chip + from pacman.data import PacmanDataView from pacman.exceptions import MachineHasDisconnectedSubRegion from pacman.model.routing_table_by_partition import ( @@ -28,6 +30,8 @@ ApplicationEdgePartition, ApplicationVertex) from pacman.model.graphs.machine import MachineVertex +from .routing_tree import RoutingTree + def get_app_partitions() -> List[ApplicationEdgePartition]: """ diff --git a/pacman/utilities/file_format_schemas/__init__.py b/pacman/utilities/file_format_schemas/__init__.py index 27ea18b4f..fb0ed3443 100644 --- a/pacman/utilities/file_format_schemas/__init__.py +++ b/pacman/utilities/file_format_schemas/__init__.py @@ -18,8 +18,10 @@ import os import json -import jsonschema from typing import Union + +import jsonschema + from spinn_utilities.typing.json import JsonArray, JsonObject, JsonObjectArray diff --git a/pylint.bash b/pylint.bash index 486854516..4ce9e3951 100644 --- a/pylint.bash +++ b/pylint.bash @@ -31,7 +31,7 @@ cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman # check one test -pylint --enable=ungrouped-imports --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman # check docs # pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman From bdcb2b6caee36348141717b26513e44293e42dbb Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 16:30:01 +0000 Subject: [PATCH 08/27] pylint: disable=import-outside-toplevel --- pacman/operations/placer_algorithms/application_placer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index 058cb8ec5..c1f075818 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -125,6 +125,7 @@ def place_application_graph(system_placements: Placements) -> Placements: chips_attempted.clear() if get_config_bool("Reports", "draw_placements"): + # pylint: disable=import-outside-toplevel from .draw_placements import draw_placements as dp dp(placements, system_placements) @@ -212,6 +213,7 @@ def _place_error( " free cores)\n") if get_config_bool("Reports", "draw_placements_on_error"): + # pylint: disable=import-outside-toplevel from .draw_placements import draw_placements as dp dp(placements, system_placements) From f51d2de2a8e2d09670911b4dde8bc3ef86f0e878 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 07:03:28 +0000 Subject: [PATCH 09/27] replace line incorrectly removed --- pacman/operations/placer_algorithms/application_placer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index c1f075818..444577fef 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -564,6 +564,7 @@ def x(self) -> int: :rtype: int """ + return self.chip.x @property def y(self) -> int: From 4435b632b8dd6d82923521c9ffb361cf83fa14d1 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 08:12:36 +0000 Subject: [PATCH 10/27] refactored to standard python method name --- pacman/model/graphs/abstract_vertex.py | 2 +- pacman/model/graphs/application/application_graph.py | 2 +- pacman/model/tags/tags.py | 2 +- pacman/operations/router_compressors/abstract_compressor.py | 2 +- .../ordered_covering_router_compressor/ordered_covering.py | 2 +- pacman/operations/router_compressors/pair_compressor.py | 2 +- pacman/operations/router_compressors/rt_entry.py | 4 ++-- pacman/utilities/utility_calls.py | 2 +- .../application_graph_tests/test_application_vertex.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pacman/model/graphs/abstract_vertex.py b/pacman/model/graphs/abstract_vertex.py index d3f80f6be..c588eb8bd 100644 --- a/pacman/model/graphs/abstract_vertex.py +++ b/pacman/model/graphs/abstract_vertex.py @@ -62,7 +62,7 @@ def set_label(self, label: str): "As Labels are also IDs they can not be changed.") self._label = label - def setAddedToGraph(self) -> None: + def set_added_to_graph(self) -> None: """ Records that the vertex has been added to a graph. diff --git a/pacman/model/graphs/application/application_graph.py b/pacman/model/graphs/application/application_graph.py index 32c4f4dc5..3b7c3983a 100644 --- a/pacman/model/graphs/application/application_graph.py +++ b/pacman/model/graphs/application/application_graph.py @@ -69,7 +69,7 @@ def add_vertex(self, vertex: ApplicationVertex): if self._vertex_by_label[vertex.label] == vertex: raise PacmanAlreadyExistsException("vertex", vertex.label) vertex.set_label(vertex.label + self._label_postfix()) - vertex.setAddedToGraph() + vertex.set_added_to_graph() self._vertex_by_label[cast(str, vertex.label)] = vertex @property diff --git a/pacman/model/tags/tags.py b/pacman/model/tags/tags.py index 9e1a2d810..83c11537d 100644 --- a/pacman/model/tags/tags.py +++ b/pacman/model/tags/tags.py @@ -77,7 +77,7 @@ def add_ip_tag(self, ip_tag: IPTag, vertex: MachineVertex): if (ip_tag.board_address, ip_tag.tag) in self._ip_tags: existing_tag = self._ip_tags[ip_tag.board_address, ip_tag.tag] if (existing_tag.ip_address != ip_tag.ip_address or - not utility_calls.is_equal_or_None( + not utility_calls.is_equal_or_none( existing_tag.port, ip_tag.port) or existing_tag.strip_sdp != ip_tag.strip_sdp): raise PacmanInvalidParameterException( diff --git a/pacman/operations/router_compressors/abstract_compressor.py b/pacman/operations/router_compressors/abstract_compressor.py index 072a863e0..c568b2ee8 100644 --- a/pacman/operations/router_compressors/abstract_compressor.py +++ b/pacman/operations/router_compressors/abstract_compressor.py @@ -109,7 +109,7 @@ def compress_tables( for entry in compressed_table: new_table.add_multicast_routing_entry( - entry.to_MulticastRoutingEntry()) + entry.to_multicast_routing_entry()) if new_table.number_of_entries > target: self._problems += ( f"(x:{new_table.x},y:{new_table.y})=" diff --git a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py index 850eb9aaf..8e0a5618e 100644 --- a/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py +++ b/pacman/operations/router_compressors/ordered_covering_router_compressor/ordered_covering.py @@ -88,7 +88,7 @@ def compress_table( target_length = chip.router.n_available_multicast_entries # Convert into a list of entries routing_table = list(map( - RTEntry.from_MulticastRoutingEntry, + RTEntry.from_multicast_routing_entry, router_table.multicast_routing_entries)) # Compress the router entries table, _ = ordered_covering( diff --git a/pacman/operations/router_compressors/pair_compressor.py b/pacman/operations/router_compressors/pair_compressor.py index 1e03eeb65..9d7a43e77 100644 --- a/pacman/operations/router_compressors/pair_compressor.py +++ b/pacman/operations/router_compressors/pair_compressor.py @@ -430,7 +430,7 @@ def compress_table( for entry in router_table.multicast_routing_entries: self._all_entries.append( - RTEntry.from_MulticastRoutingEntry(entry)) + RTEntry.from_multicast_routing_entry(entry)) self._update_frequency(entry) if self._c_sort: diff --git a/pacman/operations/router_compressors/rt_entry.py b/pacman/operations/router_compressors/rt_entry.py index d3b8ff855..6160ecd3f 100644 --- a/pacman/operations/router_compressors/rt_entry.py +++ b/pacman/operations/router_compressors/rt_entry.py @@ -58,7 +58,7 @@ def __eq__(self, other): self.spinnaker_route == other.spinnaker_route) @staticmethod - def from_MulticastRoutingEntry(source: MulticastRoutingEntry) -> RTEntry: + def from_multicast_routing_entry(source: MulticastRoutingEntry) -> RTEntry: """ :param ~spinn_machine.MulticastRoutingEntry source: :rtype: RTEntry @@ -69,7 +69,7 @@ def from_MulticastRoutingEntry(source: MulticastRoutingEntry) -> RTEntry: source._routing_entry_key, source._mask, source._defaultable, source._spinnaker_route) - def to_MulticastRoutingEntry(self) -> MulticastRoutingEntry: + def to_multicast_routing_entry(self) -> MulticastRoutingEntry: """ :rtype: ~spinn_machine.MulticastRoutingEntry """ diff --git a/pacman/utilities/utility_calls.py b/pacman/utilities/utility_calls.py index 302667f6d..15f9f0c0c 100644 --- a/pacman/utilities/utility_calls.py +++ b/pacman/utilities/utility_calls.py @@ -60,7 +60,7 @@ def compress_bits_from_bit_array( return compress_from_bit_array(expanded_value) -def is_equal_or_None(a: Any, b: Any) -> bool: +def is_equal_or_none(a: Any, b: Any) -> bool: """ If a and b are both not `None`, return True if and only if they are equal, otherwise return True. diff --git a/unittests/model_tests/application_graph_tests/test_application_vertex.py b/unittests/model_tests/application_graph_tests/test_application_vertex.py index ceabc3bd2..a6e97de58 100644 --- a/unittests/model_tests/application_graph_tests/test_application_vertex.py +++ b/unittests/model_tests/application_graph_tests/test_application_vertex.py @@ -138,7 +138,7 @@ def test_set_label(self): vert.set_label("test 1") self.assertEqual("test 1", vert.label) self.assertFalse(vert.has_been_added_to_graph()) - vert.setAddedToGraph() + vert.set_added_to_graph() with self.assertRaises(PacmanConfigurationException): vert.set_label("test 2") self.assertTrue(vert.has_been_added_to_graph()) From 75b175610d5c2da87ecbb965f3d106bc7c02068a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 08:16:45 +0000 Subject: [PATCH 11/27] remove unneccessary keys() call --- pacman/model/graphs/abstract_multiple_partition.py | 2 +- .../graphs/machine/source_segmented_sdram_machine_partition.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pacman/model/graphs/abstract_multiple_partition.py b/pacman/model/graphs/abstract_multiple_partition.py index 293854575..8208a759d 100644 --- a/pacman/model/graphs/abstract_multiple_partition.py +++ b/pacman/model/graphs/abstract_multiple_partition.py @@ -55,7 +55,7 @@ def __init__( @overrides(AbstractEdgePartition.add_edge) def add_edge(self, edge: E): # safety checks - if edge.pre_vertex not in self._pre_vertices.keys(): + if edge.pre_vertex not in self._pre_vertices: raise PacmanValueError( f"The edge {edge} is not allowed in this outgoing partition") diff --git a/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py b/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py index dec064fc8..0500deb72 100644 --- a/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py +++ b/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py @@ -66,7 +66,7 @@ def sdram_base_address(self, new_value: int): self._sdram_base_address = new_value - for pre_vertex in self._pre_vertices.keys(): + for pre_vertex in self._pre_vertices(): # allocate for the pre_vertex edge = self._pre_vertices[pre_vertex].peek() edge.sdram_base_address = new_value From b4c0e914ca3b85c016ea92663a4e8aaf74f06537 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 08:18:08 +0000 Subject: [PATCH 12/27] use list not single tuple for slots --- pacman/model/partitioner_splitters/splitter_fixed_legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py index aff347e40..da2d0cc83 100644 --- a/pacman/model/partitioner_splitters/splitter_fixed_legacy.py +++ b/pacman/model/partitioner_splitters/splitter_fixed_legacy.py @@ -41,7 +41,7 @@ class SplitterFixedLegacy(AbstractSplitterCommon[V], Generic[V]): implement :py:class:`LegacyPartitionerAPI`. """ - __slots__ = ("__slices") + __slots__ = ["__slices"] def __init__(self) -> None: super().__init__() From 4f7a30b8e7910db24819667414a502869370ca97 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 08:25:30 +0000 Subject: [PATCH 13/27] remove rouge brackets --- .../graphs/machine/source_segmented_sdram_machine_partition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py b/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py index 0500deb72..d80a7dfe0 100644 --- a/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py +++ b/pacman/model/graphs/machine/source_segmented_sdram_machine_partition.py @@ -66,7 +66,7 @@ def sdram_base_address(self, new_value: int): self._sdram_base_address = new_value - for pre_vertex in self._pre_vertices(): + for pre_vertex in self._pre_vertices: # allocate for the pre_vertex edge = self._pre_vertices[pre_vertex].peek() edge.sdram_base_address = new_value From 43445c4480b615d5b107d6491bf7da39a93bd858 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:18:08 +0000 Subject: [PATCH 14/27] f string --- pacman/model/graphs/common/slice.py | 2 +- .../multicast_routing_table_by_partition_entry.py | 9 ++++----- pacman/utilities/algorithm_utilities/routing_tree.py | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pacman/model/graphs/common/slice.py b/pacman/model/graphs/common/slice.py index 94d36a5b3..70bad8acb 100644 --- a/pacman/model/graphs/common/slice.py +++ b/pacman/model/graphs/common/slice.py @@ -44,7 +44,7 @@ def __init__(self, lo_atom: int, hi_atom: int): raise PacmanValueError('lo_atom < 0') if hi_atom < lo_atom: raise PacmanValueError( - 'hi_atom {:d} < lo_atom {:d}'.format(hi_atom, lo_atom)) + f'hi_atom {hi_atom:d} < lo_atom {lo_atom:d}') self._lo_atom = lo_atom # Number of atoms represented by this slice diff --git a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py index f2a11dfe8..be20bd791 100644 --- a/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py +++ b/pacman/model/routing_table_by_partition/multicast_routing_table_by_partition_entry.py @@ -256,11 +256,10 @@ def merge_entry(self, other: MulticastRoutingTableByPartitionEntry) -> \ return entry def __repr__(self) -> str: - return "{}:{}:{}:{{{}}}:{{{}}}".format( - self.incoming_link, self.incoming_processor, - self.defaultable, - ", ".join(map(str, self.link_ids)), - ", ".join(map(str, self.processor_ids))) + return (f"{self.incoming_link}:{self.incoming_processor}:" + f"{self.defaultable}:" + f"{{{', '.join(map(str, self.link_ids))}}}:" + f"{{{', '.join(map(str, self.processor_ids))}}}") def has_same_route( self, entry: MulticastRoutingTableByPartitionEntry) -> bool: diff --git a/pacman/utilities/algorithm_utilities/routing_tree.py b/pacman/utilities/algorithm_utilities/routing_tree.py index debef53fc..2c43cb9e4 100644 --- a/pacman/utilities/algorithm_utilities/routing_tree.py +++ b/pacman/utilities/algorithm_utilities/routing_tree.py @@ -147,10 +147,8 @@ def __iter__(self) -> Iterator[Union[RoutingTree, MachineVertex]]: yield obj def __repr__(self) -> str: - return "".format( - self.chip, - len(self._children), - "child" if len(self._children) == 1 else "children") + return f"" def traverse(self) -> Iterable[Tuple[Optional[int], XY, Set[int]]]: """ From c741f28f4e3ef67300f6425ed8133c8a2bcdd700 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:29:01 +0000 Subject: [PATCH 15/27] pylint: disable=unnecessary-lambda-assignment --- .../utilities/algorithm_utilities/routing_algorithm_utilities.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py index fab15184b..aa7c971e4 100644 --- a/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py +++ b/pacman/utilities/algorithm_utilities/routing_algorithm_utilities.py @@ -269,6 +269,7 @@ def a_star(sink: XY, heuristic_source: XY, """ machine = PacmanDataView.get_machine() # Select the heuristic function to use for distances + # pylint: disable=unnecessary-lambda-assignment heuristic = (lambda the_node: machine.get_vector_length( the_node, heuristic_source)) From aff61763a3ed1f495dbea6829f04ce4312128e8b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:38:01 +0000 Subject: [PATCH 16/27] enumerate --- .../algorithm_utilities/partition_algorithm_utilities.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pacman/utilities/algorithm_utilities/partition_algorithm_utilities.py b/pacman/utilities/algorithm_utilities/partition_algorithm_utilities.py index f42bc9167..071c5d484 100644 --- a/pacman/utilities/algorithm_utilities/partition_algorithm_utilities.py +++ b/pacman/utilities/algorithm_utilities/partition_algorithm_utilities.py @@ -56,12 +56,12 @@ def get_multidimensional_slices( total_atoms_per_core = 1 dim_numerator = [0] * len(n_atoms) total_n_atoms = 1 - for d in range(len(n_atoms)): + for d, n_atom in enumerate(n_atoms): dim_numerator[d] = n_vertices - n_this_dim = int(math.ceil(n_atoms[d] / atoms_per_core[d])) + n_this_dim = int(math.ceil(n_atom / atoms_per_core[d])) n_vertices *= n_this_dim total_atoms_per_core *= atoms_per_core[d] - total_n_atoms *= n_atoms[d] + total_n_atoms *= n_atom # Run over all the vertices and create slices for them slices: List[Slice] = list() From c366b4878e498dbd7a47c8bc7bec875881f3f200 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:44:46 +0000 Subject: [PATCH 17/27] pylint: disable=import-error,import-outside-toplevel --- pacman/operations/placer_algorithms/_spinner_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/operations/placer_algorithms/_spinner_api.py b/pacman/operations/placer_algorithms/_spinner_api.py index a07be68ae..0993b63ea 100644 --- a/pacman/operations/placer_algorithms/_spinner_api.py +++ b/pacman/operations/placer_algorithms/_spinner_api.py @@ -47,7 +47,7 @@ def import_api() -> 'Spinner': :raises ImportError: if on Windows """ # spinner as graphical library so - # pylint: disable=import-error + # pylint: disable=import-error,import-outside-toplevel # Depends on Cairo, which is virtually never there on Windows. # We could catch the OSError, but that's very noisy in this case From dcb2f14e62675ca371be3658e44400d4dbc51b4b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:45:10 +0000 Subject: [PATCH 18/27] manual run file updated --- pylint.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint.bash b/pylint.bash index 4ce9e3951..ec5ff3184 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,10 +28,10 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # check all -# pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman +pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman # check one test -pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +# pylint --enable=consider-using-f-string --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman # check docs # pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman From 702b4c65571d6f44533daf978e99a5e97c453a50 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 09:51:14 +0000 Subject: [PATCH 19/27] avoid using IE --- pacman/utilities/algorithm_utilities/routing_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/utilities/algorithm_utilities/routing_tree.py b/pacman/utilities/algorithm_utilities/routing_tree.py index 2c43cb9e4..849aea8a2 100644 --- a/pacman/utilities/algorithm_utilities/routing_tree.py +++ b/pacman/utilities/algorithm_utilities/routing_tree.py @@ -127,7 +127,7 @@ def remove_child( @property def is_leaf(self) -> bool: """ - Detect if this is a leaf node. IE has no children. + Detect if this is a leaf node, which is one with no children. :return: """ return not self._children From 08609819d9285e72be6b9cfb0fa82f134789e8a7 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 5 Feb 2024 10:00:39 +0000 Subject: [PATCH 20/27] more typing --- pacman/utilities/json_utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pacman/utilities/json_utils.py b/pacman/utilities/json_utils.py index 84935f393..f0a3b407a 100644 --- a/pacman/utilities/json_utils.py +++ b/pacman/utilities/json_utils.py @@ -58,7 +58,7 @@ def key_mask_to_json(key_mask: BaseKeyAndMask) -> JsonObject: :rtype: dict(str, object) """ try: - json_object = dict() + json_object: JsonObject = dict() json_object["key"] = key_mask.key json_object["mask"] = key_mask.mask except Exception as ex: # pylint: disable=broad-except @@ -73,7 +73,7 @@ def iptag_resource_to_json(iptag: IPtagResource) -> JsonObject: :param IPtagResource iptag: :rtype: dict(str, object) """ - json_dict = dict() + json_dict: JsonObject = dict() try: json_dict["ip_address"] = iptag.ip_address if iptag.port is not None: @@ -108,7 +108,7 @@ def iptag_resources_to_json(iptags: List[IPtagResource]) -> JsonArray: :param list(IPtagResource) iptags: :rtype: list """ - json_list = [] + json_list: JsonArray = [] for iptag in iptags: json_list.append(iptag_resource_to_json(iptag)) return json_list @@ -134,7 +134,7 @@ def reverse_iptag_to_json(iptag: ReverseIPtagResource) -> JsonObject: :param ReverseIPtagResource iptag: :rtype: dict(object) """ - json_dict = dict() + json_dict: JsonObject = dict() try: if iptag.port is not None: json_dict["port"] = iptag.port @@ -166,7 +166,7 @@ def reverse_iptags_to_json(iptags: List[ReverseIPtagResource]) -> JsonArray: :param list(ReverseIPtagResource) iptags: :rtype: list """ - json_list = [] + json_list: JsonArray = [] for iptag in iptags: json_list.append(reverse_iptag_to_json(iptag)) return json_list @@ -193,7 +193,7 @@ def vertex_to_json(vertex: MachineVertex) -> JsonObject: :param MachineVertex vertex: :rtype: dict(str, object) """ - json_dict = dict() + json_dict: JsonObject = dict() try: json_dict["class"] = vertex.__class__.__name__ json_dict["label"] = vertex.label @@ -246,7 +246,7 @@ def placement_to_json(placement: Placement) -> JsonObject: :param Placement placement: :rtype: dict(str, object) """ - json_dict = dict() + json_dict: JsonObject = dict() try: json_dict["vertex_label"] = placement.vertex.label json_dict["x"] = placement.x @@ -261,7 +261,7 @@ def placements_to_json() -> JsonArray: """ Gets a json description of the placements (held in DataView) """ - json_list = [] + json_list: JsonArray = [] for placement in PacmanDataView.iterate_placemements(): json_list.append(placement_to_json(placement)) return json_list From 9c9edb7dc117588c4a11380d16d02f11885bceb9 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 12 Feb 2024 16:35:39 +0000 Subject: [PATCH 21/27] small changes to avoid spelling exception --- .../router_compressors/pair_compressor.py | 4 ++-- .../operations/router_compressors/rt_entry.py | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pacman/operations/router_compressors/pair_compressor.py b/pacman/operations/router_compressors/pair_compressor.py index 9d7a43e77..ade33957f 100644 --- a/pacman/operations/router_compressors/pair_compressor.py +++ b/pacman/operations/router_compressors/pair_compressor.py @@ -31,7 +31,7 @@ def pair_compressor( A flag which should only be used in testing to stop raising an exception if result is too big :param bool verify: If set to true will verify the length before returning - :param bool c_sort: If set will use the slower quicksort as it is + :param bool c_sort: If set will use the slower quick sort as it is implemented in c/ on cores :rtype: MulticastRoutingTables """ @@ -148,7 +148,7 @@ class _PairCompressor(AbstractCompressor): # A list of all entries which may be sorted # of entries represented as (key, mask, defaultable) "_all_entries", - # flag to use slower quicksort as it is implemented in c/ on cores + # flag to use slower quick sort as it is implemented in c/ on cores "_c_sort", # The next index to write a merged/unmergeable entry to "_write_index", diff --git a/pacman/operations/router_compressors/rt_entry.py b/pacman/operations/router_compressors/rt_entry.py index 6160ecd3f..d821c9784 100644 --- a/pacman/operations/router_compressors/rt_entry.py +++ b/pacman/operations/router_compressors/rt_entry.py @@ -21,16 +21,16 @@ class RTEntry(object): table compressors. Essentially a tuple and compacted version of :py:class:`~spinn_machine.MulticastRoutingEntry`. - :ivar key: The key - :vartype key: int - :ivar mask: The mask - :vartype mask: int - :ivar defaultable: Whether the route may be handled by default routing - :vartype defaultable: bool - :ivar spinnaker_route: The route - :vartype spinnaker_route: int - :ivar key_mask: The key,mask pair - :vartype key_mask: tuple(int,int) + :param key: The key + :type key: int + :param mask: The mask + :type mask: int + :param defaultable: Whether the route may be handled by default routing + :type defaultable: bool + :param spinnaker_route: The route + :type spinnaker_route: int + :param key_mask: The key,mask pair + :type key_mask: tuple(int,int) """ __slots__ = ("key", "mask", "defaultable", "spinnaker_route", "key_mask") From 4a1d06b274b4721c548ffabc0771bf8a37fcd10c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 12 Feb 2024 16:36:48 +0000 Subject: [PATCH 22/27] move spelling exceptions to support scripts --- .pylint_dict.txt | 41 +++-------------------------------------- pylint.bash | 11 +++-------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index 2b64ca969..734b056d8 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -12,42 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Our abbreviations/names -Navaridas -NER - -# Our types -AbstractEdgePartition -AbstractSDRAMPartition -AbstractSingleSourcePartition -BaseKeyAndMask -ChipAndCore -MulticastEdgePartition -PacmanAlreadyExistsException -PlacementTuple -ReverseIPtagResource -RoutingInfo -RoutingTree -RTEntry -SDRAMMachineEdge -ValidationError - -# Python packages -jsonschema - -# Python bits -maxsize - -# Our special words -heapq -mergable -precompressed -precompression -precompressor -quicksort -obj -reorderable -subobj -unmergeable -vartype +# We use a single exception files for all the main repsitories +# It can be found at: +# https://github.com/SpiNNakerManchester/SupportScripts/blob/master/actions/pylint/default_dict.txt diff --git a/pylint.bash b/pylint.bash index ec5ff3184..a791a3be3 100644 --- a/pylint.bash +++ b/pylint.bash @@ -22,17 +22,12 @@ # requires the spelling dicts # sudo apt-get -o Dpkg::Use-Pty=0 install --fix-missing enchant-2 hunspell hunspell-en-gb -dict=/tmp/dict.txt - -cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict -cat ".pylint_dict.txt" >>$dict - # check all -pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error pacman +pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=import-error pacman # check one test -# pylint --enable=consider-using-f-string --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +# pylint --enable=consider-using-f-string --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all pacman # check docs -# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all pacman +# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all pacman From ed5fca355e0f8764d8d535da5f561605c193b848 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 06:47:44 +0000 Subject: [PATCH 23/27] use pylint rcfile in SupportScripts --- .pylintrc | 473 ------------------------------------------------------ 1 file changed, 473 deletions(-) delete mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 456ee1f65..000000000 --- a/.pylintrc +++ /dev/null @@ -1,473 +0,0 @@ -# Copyright (c) 2019 The University of Manchester -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. - -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist=numpy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=R,C,unsubscriptable-object -# False positives for unsubscriptable-object. Mypy better at this class of issue -# See https://github.com/pylint-dev/pylint/issues/1498 - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member,C0402,C0403 - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=optparse.Values,sys.exit - - -[BASIC] - -# Naming style matching correct argument names -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style -#argument-rgx= - -# Naming style matching correct attribute names -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style -#class-attribute-rgx= - -# Naming style matching correct class names -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming-style -#class-rgx= - -# Naming style matching correct constant names -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma -good-names=i, - j, - k, - ex, - Run, - _ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming style matching correct inline iteration names -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style -#inlinevar-rgx= - -# Naming style matching correct method names -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style -#method-rgx= - -# Naming style matching correct module names -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style -#variable-rgx= - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging,FormatAdapter - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=numpy.* - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local,numpy - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=numpy - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - __call__, - _clear, - _hard_reset, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception From 45a30f0ed8f6f40cf49a9ee2598e851deb735b8c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 12:31:53 +0000 Subject: [PATCH 24/27] temporarily add other spinnaker repositories --- import_hook.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 import_hook.py diff --git a/import_hook.py b/import_hook.py new file mode 100644 index 000000000..c6ee2f432 --- /dev/null +++ b/import_hook.py @@ -0,0 +1,27 @@ +# Copyright (c) 2017 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +""" +This file is imported by init-hook in the rcfile +https://github.com/SpiNNakerManchester/SupportScripts/blob/master/actions/pylint/strict_rcfile + +It allows you to temporarily add the other spinnaker repositories without making them part of the permemnant python path + +Intended for use when running pylint.bash +""" +import sys +sys.path.append("../SpiNNUtils") +sys.path.append("../SpiNNMachine") +sys.path.append("../SpiNNMan") +sys.path.append("../spalloc") From 6fb15dfb18ff3f4ba1c832566dc34fb146548fbe Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 29 Feb 2024 06:41:35 +0000 Subject: [PATCH 25/27] use SupportScripts/actions/pylint/strict_rcfile for pylint --- .github/workflows/python_actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 41ca9aea1..171f8f871 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -74,6 +74,7 @@ jobs: package: ${{ env.BASE_PKG }} exitcheck: 31 # Action fails on any message language: en_GB + rcfile: global_strict - name: Lint with mypy run: mypy $BASE_PKG From 1c98b82a34fad3b3a188058cc46d037ed7688e1c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 29 Feb 2024 06:59:37 +0000 Subject: [PATCH 26/27] fix spellings in comments --- pacman/operations/router_compressors/pair_compressor.py | 2 +- pacman/operations/router_compressors/ranged_compressor.py | 2 +- .../zoned_routing_info_allocator.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pacman/operations/router_compressors/pair_compressor.py b/pacman/operations/router_compressors/pair_compressor.py index ade33957f..d9ef4dcea 100644 --- a/pacman/operations/router_compressors/pair_compressor.py +++ b/pacman/operations/router_compressors/pair_compressor.py @@ -513,7 +513,7 @@ def merge(self, entry1: RTEntry, entry2: RTEntry) -> Tuple[int, int, bool]: # Compute the new mask and key any_zeros = ~all_ones new_xs = any_ones ^ any_zeros - mask = all_selected & new_xs # Combine existing and new X's + mask = all_selected & new_xs key = all_ones & mask return key, mask, entry1.defaultable and entry2.defaultable diff --git a/pacman/operations/router_compressors/ranged_compressor.py b/pacman/operations/router_compressors/ranged_compressor.py index c7ce6d592..4d911e9fb 100644 --- a/pacman/operations/router_compressors/ranged_compressor.py +++ b/pacman/operations/router_compressors/ranged_compressor.py @@ -176,7 +176,7 @@ def _merge_range(self, first: int, last: int): dif = last_point - first_point power = 1 if dif < 1 else 1 << ((dif - 1).bit_length()) - # Find the start range cutoffs + # Find the start range cut-offs low_cut = first_point // power * power high_cut = low_cut + power diff --git a/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py b/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py index 49abe6c4b..2c31e1b9f 100644 --- a/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py +++ b/pacman/operations/routing_info_allocator_algorithms/zoned_routing_info_allocator.py @@ -88,9 +88,9 @@ class ZonedRoutingInfoAllocator(object): # maximum number of bites to represent the keys and masks # for a single app vertex / partition name zone "__n_bits_atoms_and_mac", - # Maximum number pf bit to represent the machine assuming global + # Maximum number of bits to represent the machine assuming global "__n_bits_machine", - # Maximum number pf bit to represent the machine assuming global + # Maximum number of bits to represent the machine assuming global "__n_bits_atoms", # Flag to say operating in flexible mode "__flexible", From 6e68dbb48d4d5ae85ae3a3c44a236e9dd657f2e1 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 29 Feb 2024 07:30:03 +0000 Subject: [PATCH 27/27] please the spell checker --- pacman/operations/router_compressors/ranged_compressor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/operations/router_compressors/ranged_compressor.py b/pacman/operations/router_compressors/ranged_compressor.py index 4d911e9fb..8f620afd0 100644 --- a/pacman/operations/router_compressors/ranged_compressor.py +++ b/pacman/operations/router_compressors/ranged_compressor.py @@ -176,7 +176,7 @@ def _merge_range(self, first: int, last: int): dif = last_point - first_point power = 1 if dif < 1 else 1 << ((dif - 1).bit_length()) - # Find the start range cut-offs + # Find the start range cut-off low_cut = first_point // power * power high_cut = low_cut + power