• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNMan / 6574804013

19 Oct 2023 12:47PM UTC coverage: 51.937% (+1.2%) from 50.777%
6574804013

Pull #327

github

Christian-B
typing changes
Pull Request #327: Type Annotations and Checking

105 of 1288 branches covered (0.0%)

Branch coverage included in aggregate %.

2375 of 2375 new or added lines in 180 files covered. (100.0%)

4775 of 8108 relevant lines covered (58.89%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.54
/spinnman/processes/most_direct_connection_selector.py
1
# Copyright (c) 2015 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
from typing import Dict, List
1✔
15
from spinn_utilities.overrides import overrides
1✔
16
from spinn_utilities.typing.coords import XY
1✔
17
from spinnman.data import SpiNNManDataView
1✔
18
from spinnman.connections.udp_packet_connections import SCAMPConnection
1✔
19
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
20
from .abstract_multi_connection_process_connection_selector import (
1✔
21
    ConnectionSelector)
22

23

24
class MostDirectConnectionSelector(ConnectionSelector):
1✔
25
    """
26
    A selector that goes for the most direct connection for the message.
27
    """
28
    __slots__ = (
1✔
29
        "_connections",
30
        "_lead_connection")
31

32
    def __init__(self, connections: List[SCAMPConnection]):
1✔
33
        """
34
        :param list(SCAMPConnection) connections:
35
            The connections to be used
36
        """
37
        self._connections: Dict[XY, SCAMPConnection] = dict()
1✔
38
        lead_connection = None
1✔
39
        for conn in connections:
1✔
40
            if conn.chip_x == 0 and conn.chip_y == 0:
1!
41
                lead_connection = conn
×
42
            self._connections[conn.chip_x, conn.chip_y] = conn
1✔
43
        if lead_connection is None:
1!
44
            lead_connection = next(iter(connections))
1✔
45
        self._lead_connection = lead_connection
1✔
46

47
    @overrides(ConnectionSelector.get_next_connection)
1✔
48
    def get_next_connection(
1✔
49
            self, message: AbstractSCPRequest) -> SCAMPConnection:
50
        key = (message.sdp_header.destination_chip_x,
×
51
               message.sdp_header.destination_chip_y)
52
        if key in self._connections:
×
53
            return self._connections[key]
×
54

55
        if not SpiNNManDataView.has_machine() or len(self._connections) == 1:
×
56
            return self._lead_connection
×
57

58
        x, y = key
×
59
        key = SpiNNManDataView.get_nearest_ethernet(x, y)
×
60

61
        return self._connections.get(key, self._lead_connection)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc