• 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

85.82
/spinnman/transceiver/mockable_transceiver.py
1
# Copyright (c) 2014 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

15
# pylint: disable=too-many-arguments
16

17
from typing import (
1✔
18
    BinaryIO, Collection, Dict, FrozenSet, Iterable,
19
    List, Optional, Tuple, Union)
20
from spinn_utilities.overrides import overrides
1✔
21
from spinn_utilities.progress_bar import ProgressBar
1✔
22
from spinn_utilities.typing.coords import XY
1✔
23
from spinn_machine import (
1✔
24
    CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry)
25
from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag
1✔
26
from spinnman.data import SpiNNManDataView
1✔
27
from spinnman.connections.udp_packet_connections import BMPConnection
1✔
28
from spinnman.connections.udp_packet_connections import (
1✔
29
    SCAMPConnection, SDPConnection)
30
from spinnman.processes import ConnectionSelector, FixedConnectionSelector
1✔
31
from spinnman.messages.scp.enums import Signal
1✔
32
from spinnman.messages.sdp import SDPMessage
1✔
33
from spinnman.model import (
1✔
34
    CPUInfos, DiagnosticFilter, IOBuffer, RouterDiagnostics,
35
    VersionInfo)
36
from spinnman.model.enums import CPUState, UserRegister
1✔
37
from spinnman.transceiver.transceiver import Transceiver
1✔
38
from spinnman.transceiver.extendable_transceiver import ExtendableTransceiver
1✔
39
from spinnman.processes import MostDirectConnectionSelector
1✔
40

41

42
class MockableTransceiver(ExtendableTransceiver):
1✔
43
    """
44
    A based for Mock Transceivers
45
    """
46
    __slots__ = ["written_memory"]
1✔
47

48
    def __init__(self) -> None:
1✔
49
        super().__init__()
1✔
50
        self.written_memory: List[
1✔
51
            Tuple[int, int, int, Union[BinaryIO, bytes, int, str],
52
                  Optional[int], int, int]] = []
53

54
    @overrides(Transceiver.send_sdp_message)
1✔
55
    def send_sdp_message(self, message: SDPMessage,
1✔
56
                         connection: Optional[SDPConnection] = None):
57
        pass
×
58

59
    @overrides(Transceiver.discover_scamp_connections)
1✔
60
    def discover_scamp_connections(self) -> None:
1✔
61
        raise NotImplementedError("Needs to be mocked")
62

63
    @overrides(Transceiver.add_scamp_connections)
1✔
64
    def add_scamp_connections(self, connections: Dict[XY, str]):
1✔
65
        pass
×
66

67
    @overrides(Transceiver.get_machine_details)
1✔
68
    def get_machine_details(self) -> Machine:
1✔
69
        return SpiNNManDataView.get_machine()
1✔
70

71
    @overrides(Transceiver.get_connections)
1✔
72
    def get_connections(self):
1✔
73
        raise NotImplementedError("Needs to be mocked")
74

75
    @overrides(Transceiver.get_cpu_infos)
1✔
76
    def get_cpu_infos(
1✔
77
            self, core_subsets: Optional[CoreSubsets] = None,
78
            states: Union[CPUState, Iterable[CPUState], None] = None,
79
            include: bool = True) -> CPUInfos:
80
        raise NotImplementedError("Needs to be mocked")
81

82
    @overrides(Transceiver.get_clock_drift)
1✔
83
    def get_clock_drift(self, x, y):
1✔
84
        raise NotImplementedError("Needs to be mocked")
85

86
    @overrides(Transceiver.read_user)
1✔
87
    def read_user(self, x: int, y: int, p: int, user: UserRegister):
1✔
88
        raise NotImplementedError("Needs to be mocked")
89

90
    @overrides(Transceiver.add_cpu_information_from_core)
1✔
91
    def add_cpu_information_from_core(
1✔
92
            self, cpu_infos: CPUInfos, x: int, y: int, p: int,
93
            states: Iterable[CPUState]):
94
        raise NotImplementedError("Needs to be mocked")
95

96
    @overrides(Transceiver.get_region_base_address)
1✔
97
    def get_region_base_address(self, x: int, y: int, p: int):
1✔
98
        raise NotImplementedError("Needs to be mocked")
99

100
    @overrides(Transceiver.get_iobuf)
1✔
101
    def get_iobuf(self, core_subsets: Optional[CoreSubsets] = None
1✔
102
                  ) -> Iterable[IOBuffer]:
103
        raise NotImplementedError("Needs to be mocked")
104

105
    @overrides(Transceiver.get_core_state_count)
1✔
106
    def get_core_state_count(
1✔
107
            self, app_id: int, state: CPUState,
108
            xys: Optional[Iterable[Tuple[int, int]]] = None) -> int:
109
        raise NotImplementedError("Needs to be mocked")
110

111
    @overrides(Transceiver.execute_flood)
1✔
112
    def execute_flood(
1✔
113
            self, core_subsets: CoreSubsets,
114
            executable: Union[BinaryIO, bytes, str], app_id: int, *,
115
            n_bytes: Optional[int] = None, wait: bool = False):
116
        pass
×
117

118
    @overrides(Transceiver.read_fpga_register)
1✔
119
    def read_fpga_register(
1✔
120
            self, fpga_num: int, register: int, board: int = 0) -> int:
121
        raise NotImplementedError("Needs to be mocked")
122

123
    @overrides(Transceiver.write_fpga_register)
1✔
124
    def write_fpga_register(
1✔
125
            self, fpga_num: int, register: int, value: int, board: int = 0):
126
        pass
×
127

128
    @overrides(Transceiver.read_bmp_version)
1✔
129
    def read_bmp_version(self, board: int) -> VersionInfo:
1✔
130
        raise NotImplementedError("Needs to be mocked")
131

132
    @overrides(Transceiver.write_memory)
1✔
133
    def write_memory(
1✔
134
            self, x: int, y: int, base_address: int,
135
            data: Union[BinaryIO, bytes, int, str], *,
136
            n_bytes: Optional[int] = None, offset: int = 0, cpu: int = 0,
137
            get_sum: bool = False) -> Tuple[int, int]:
138
        print("Doing write to", x, y)
1✔
139
        self.written_memory.append(
1✔
140
            (x, y, base_address, data, n_bytes, offset, cpu))
141
        # Hope the return is never used as it will be wrong
142
        return (-1, -1)
1✔
143

144
    @overrides(Transceiver.write_user)
1✔
145
    def write_user(
1✔
146
            self, x: int, y: int, p: int, user: UserRegister, value: int):
147
        pass
×
148

149
    @overrides(Transceiver.read_memory)
1✔
150
    def read_memory(
1✔
151
            self, x: int, y: int, base_address: int, length: int,
152
            cpu: int = 0) -> bytes:
153
        raise NotImplementedError("Needs to be mocked")
154

155
    @overrides(Transceiver.read_word)
1✔
156
    def read_word(
1✔
157
            self, x: int, y: int, base_address: int, cpu: int = 0) -> int:
158
        raise NotImplementedError("Needs to be mocked")
159

160
    @overrides(Transceiver.stop_application)
1✔
161
    def stop_application(self, app_id: int):
1✔
162
        pass
×
163

164
    @overrides(Transceiver.wait_for_cores_to_be_in_state)
1✔
165
    def wait_for_cores_to_be_in_state(
1✔
166
            self, all_core_subsets: CoreSubsets, app_id: int,
167
            cpu_states: Union[CPUState, Iterable[CPUState]], *,
168
            timeout: Optional[float] = None,
169
            time_between_polls: float = 0.1,
170
            error_states: FrozenSet[CPUState] = frozenset((
171
                CPUState.RUN_TIME_EXCEPTION, CPUState.WATCHDOG)),
172
            counts_between_full_check: int = 100,
173
            progress_bar: Optional[ProgressBar] = None):
174
        pass
×
175

176
    @overrides(Transceiver.send_signal)
1✔
177
    def send_signal(self, app_id: int, signal: Signal):
1✔
178
        pass
×
179

180
    @overrides(Transceiver.set_ip_tag)
1✔
181
    def set_ip_tag(self, ip_tag: IPTag, use_sender: bool = False):
1✔
182
        pass
×
183

184
    @overrides(Transceiver.set_reverse_ip_tag)
1✔
185
    def set_reverse_ip_tag(self, reverse_ip_tag: ReverseIPTag):
1✔
186
        pass
×
187

188
    @overrides(Transceiver.clear_ip_tag)
1✔
189
    def clear_ip_tag(self, tag: int, board_address: Optional[str] = None):
1✔
190
        pass
×
191

192
    @overrides(Transceiver.get_tags)
1✔
193
    def get_tags(self, connection: Optional[SCAMPConnection] = None
1✔
194
                 ) -> Iterable[AbstractTag]:
195
        raise NotImplementedError("Needs to be mocked")
196

197
    @overrides(Transceiver.malloc_sdram)
1✔
198
    def malloc_sdram(
1✔
199
            self, x: int, y: int, size: int, app_id: int, tag=0) -> int:
200
        raise NotImplementedError("Needs to be mocked")
201

202
    @overrides(Transceiver.load_multicast_routes)
1✔
203
    def load_multicast_routes(
1✔
204
            self, x: int, y: int, routes: Collection[MulticastRoutingEntry],
205
            app_id: int):
206
        pass
×
207

208
    @overrides(Transceiver.load_fixed_route)
1✔
209
    def load_fixed_route(
1✔
210
            self, x: int, y: int, fixed_route: FixedRouteEntry, app_id: int):
211
        pass
×
212

213
    @overrides(Transceiver.read_fixed_route)
1✔
214
    def read_fixed_route(self, x: int, y: int, app_id: int) -> FixedRouteEntry:
1✔
215
        raise NotImplementedError("Needs to be mocked")
216

217
    @overrides(Transceiver.get_multicast_routes)
1✔
218
    def get_multicast_routes(
1✔
219
            self, x: int, y: int,
220
            app_id: Optional[int] = None) -> List[MulticastRoutingEntry]:
221
        raise NotImplementedError("Needs to be mocked")
222

223
    @overrides(Transceiver.clear_multicast_routes)
1✔
224
    def clear_multicast_routes(self, x: int, y: int):
1✔
225
        pass
×
226

227
    @overrides(Transceiver.get_router_diagnostics)
1✔
228
    def get_router_diagnostics(self, x: int, y: int) -> RouterDiagnostics:
1✔
229
        raise NotImplementedError("Needs to be mocked")
230

231
    @overrides(Transceiver.get_scamp_connection_selector)
1✔
232
    def get_scamp_connection_selector(self) -> MostDirectConnectionSelector:
1✔
233
        raise NotImplementedError("Needs to be mocked")
234

235
    @overrides(Transceiver.set_router_diagnostic_filter)
1✔
236
    def set_router_diagnostic_filter(
1✔
237
            self, x: int, y: int, position: int,
238
            diagnostic_filter: DiagnosticFilter):
239
        pass
×
240

241
    @overrides(Transceiver.clear_router_diagnostic_counters)
1✔
242
    def clear_router_diagnostic_counters(self, x: int, y: int):
1✔
243
        pass
×
244

245
    @overrides(Transceiver.close)
1✔
246
    def close(self) -> None:
1✔
247
        pass
1✔
248

249
    @overrides(Transceiver.control_sync)
1✔
250
    def control_sync(self, do_sync: bool):
1✔
251
        pass
×
252

253
    @overrides(Transceiver.update_provenance_and_exit)
1✔
254
    def update_provenance_and_exit(self, x: int, y: int, p: int):
1✔
255
        pass
×
256

257
    @overrides(Transceiver.send_chip_update_provenance_and_exit)
1✔
258
    def send_chip_update_provenance_and_exit(self, x: int, y: int, p: int):
1✔
259
        pass
×
260

261
    @property
1✔
262
    @overrides(ExtendableTransceiver.bmp_selector)
1✔
263
    def bmp_selector(self) -> Optional[FixedConnectionSelector[BMPConnection]]:
1✔
264
        raise NotImplementedError("Needs to be mocked")
265

266
    @property
1✔
267
    @overrides(ExtendableTransceiver.scamp_connection_selector)
1✔
268
    def scamp_connection_selector(self) -> ConnectionSelector:
1✔
269
        raise NotImplementedError("Needs to be mocked")
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