• 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

50.0
/spinnman/transceiver/virtual5Transceiver.py
1
# Copyright (c) 2023 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
14
# return 0the License.
15

16
from typing import Dict, Iterable, Optional, Union
1✔
17
from spinn_utilities.overrides import overrides
1✔
18
from spinn_machine import CoreSubsets, Machine, virtual_machine
1✔
19
from spinnman.constants import N_RETRIES
1✔
20
from spinnman.exceptions import SpinnmanIOException
1✔
21
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
22
from spinnman.messages.spinnaker_boot import SystemVariableDefinition
1✔
23
from spinnman.model import CPUInfos, VersionInfo
1✔
24
from spinnman.model.enums import CPUState
1✔
25
from spinnman.processes import ConnectionSelector
1✔
26
from .version5transceiver import Version5Transceiver
1✔
27

28

29
class Virtual5Transceiver(Version5Transceiver):
1✔
30
    """
31
    Overwrites the standard Version 5 Transceiver
32
    to intercept the sending of messages.
33

34
    This is just enough different to pass know tests.
35
    Extend for new tests!
36
    """
37

38
    @overrides(Version5Transceiver._boot_board)
1✔
39
    def _boot_board(self, extra_boot_values: Optional[Dict[
1✔
40
            SystemVariableDefinition, object]] = None):
41
        try:
×
42
            super()._boot_board(extra_boot_values)
×
43
        except SpinnmanIOException:
×
44
            pass
×
45

46
    @overrides(Version5Transceiver.read_memory)
1✔
47
    def read_memory(
1✔
48
            self, x: int, y: int, base_address: int, length: int,
49
            cpu: int = 0) -> bytes:
50
        try:
×
51
            return super().read_memory(x, y, base_address, length, cpu)
×
52
        except SpinnmanIOException as exc:
×
53
            if (x == y == 255 and base_address == 4110450434):
×
54
                return bytearray(b'\x08\x08')
×
55
            raise NotImplementedError(
56
                f"Unexpected {x=} {y=} {base_address=}, {length=} {cpu=}") \
57
                from exc
58

59
    @overrides(Version5Transceiver._get_scamp_version)
1✔
60
    def _get_scamp_version(
1✔
61
            self, chip_x: int = AbstractSCPRequest.DEFAULT_DEST_X_COORD,
62
            chip_y: int = AbstractSCPRequest.DEFAULT_DEST_Y_COORD,
63
            connection_selector: Optional[ConnectionSelector] = None,
64
            n_retries: int = N_RETRIES) -> VersionInfo:
65
        try:
×
66
            return super()._get_scamp_version(
×
67
                chip_x, chip_y, connection_selector, n_retries)
68
        except SpinnmanIOException:
×
69
            version = VersionInfo(
×
70
                b'@\x00\x07\x08\xff\x00\x00\x00\x00\x00\x80\x00\x02\x00\x00\n'
71
                b'\x00\x00\x00\x01\xff\xffoa\xa3bSC&MP/SpiNNaker\x003.4.2\x00',
72
                offset=14)
73
            return version
×
74

75
    @overrides(Version5Transceiver.get_machine_details)
1✔
76
    def get_machine_details(self) -> Machine:
1✔
77
        try:
×
78
            return super().get_machine_details()
×
79
        except SpinnmanIOException:
×
80
            return virtual_machine(8, 8)
×
81

82
    @overrides(Version5Transceiver.get_cpu_infos)
1✔
83
    def get_cpu_infos(
1✔
84
            self, core_subsets: Optional[CoreSubsets] = None,
85
            states: Union[CPUState, Iterable[CPUState], None] = None,
86
            include: bool = True) -> CPUInfos:
87
        try:
×
88
            return super().get_cpu_infos(core_subsets, states, include)
×
89
        except SpinnmanIOException:
×
90
            # return an empty
91
            return CPUInfos()
×
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