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

SpiNNakerManchester / sPyNNaker / 6926841393

20 Nov 2023 07:26AM UTC coverage: 63.16% (+1.6%) from 61.529%
6926841393

Pull #1342

github

Christian-B
Merge
Pull Request #1342: Type Annotations and Checking

1961 of 4484 branches covered (0.0%)

Branch coverage included in aggregate %.

4160 of 5093 new or added lines in 233 files covered. (81.68%)

193 existing lines in 78 files now uncovered.

12735 of 18784 relevant lines covered (67.8%)

0.68 hits per line

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

31.25
/spynnaker/pyNN/models/spike_source/spike_source_array_machine_vertex.py
1
# Copyright (c) 2022 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 __future__ import annotations
1✔
15
import numpy
1✔
16
from typing import cast, TYPE_CHECKING
1✔
17
from spinn_utilities.overrides import overrides
1✔
18
from pacman.utilities.utility_calls import get_field_based_keys
1✔
19
from spinn_front_end_common.utility_models import (
1✔
20
    ReverseIPTagMulticastSourceMachineVertex)
21
from spynnaker.pyNN.data.spynnaker_data_view import SpynnakerDataView
1✔
22
if TYPE_CHECKING:
23
    from .spike_source_array_vertex import SpikeSourceArrayVertex
24

25

26
class SpikeSourceArrayMachineVertex(ReverseIPTagMulticastSourceMachineVertex):
1✔
27
    """
28
    Extended to add colour.
29
    """
30

31
    @property
1✔
32
    def _pop_vertex(self) -> SpikeSourceArrayVertex:
1✔
33
        return cast('SpikeSourceArrayVertex', self.app_vertex)
1✔
34

35
    @overrides(
1✔
36
        ReverseIPTagMulticastSourceMachineVertex.get_n_keys_for_partition)
37
    def get_n_keys_for_partition(self, partition_id: str) -> int:
1✔
38
        n_keys = super().get_n_keys_for_partition(partition_id)
1✔
39
        n_colours = 2 ** self._pop_vertex.n_colour_bits
1✔
40
        return n_keys * n_colours
1✔
41

42
    @overrides(ReverseIPTagMulticastSourceMachineVertex._fill_send_buffer_1d)
1✔
43
    def _fill_send_buffer_1d(self, key_base: int):
1✔
44
        first_time_step = SpynnakerDataView.get_first_machine_time_step()
×
45
        end_time_step = SpynnakerDataView.get_current_run_timesteps()
×
46
        if first_time_step == end_time_step:
×
47
            return
×
NEW
48
        if self._send_buffer_times is None or self._send_buffer is None:
×
NEW
49
            return
×
UNCOV
50
        keys = get_field_based_keys(
×
51
            key_base, self.vertex_slice, self._pop_vertex.n_colour_bits)
52
        key_list = numpy.array(
×
53
            [keys[atom] for atom in range(self.vertex_slice.n_atoms)])
NEW
54
        colour_mask = (2 ** self._pop_vertex.n_colour_bits) - 1
×
55
        for tick in sorted(self._send_buffer_times):
×
56
            if self._is_in_range(tick, first_time_step, end_time_step):
×
57
                self._send_buffer.add_keys(
×
58
                    tick, key_list + (tick & colour_mask))
59

60
    @overrides(ReverseIPTagMulticastSourceMachineVertex._fill_send_buffer_2d)
1✔
61
    def _fill_send_buffer_2d(self, key_base: int):
1✔
62
        first_time_step = SpynnakerDataView.get_first_machine_time_step()
×
63
        end_time_step = SpynnakerDataView.get_current_run_timesteps()
×
64
        if first_time_step == end_time_step:
×
65
            return
×
NEW
66
        if self._send_buffer_times is None or self._send_buffer is None:
×
NEW
67
            return
×
UNCOV
68
        keys = get_field_based_keys(
×
69
            key_base, self.vertex_slice, self._pop_vertex.n_colour_bits)
NEW
70
        colour_mask = (2 ** self._pop_vertex.n_colour_bits) - 1
×
71
        for atom in range(self.vertex_slice.n_atoms):
×
72
            for tick in sorted(self._send_buffer_times[atom]):
×
73
                if self._is_in_range(tick, first_time_step, end_time_step):
×
74
                    self._send_buffer.add_key(
×
75
                        tick, keys[atom] + (tick & colour_mask))
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

© 2026 Coveralls, Inc