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

SpiNNakerManchester / PACMAN / 4765810084

pending completion
4765810084

push

github

Donal K. Fellows
Improve github integration

1511 of 1978 branches covered (76.39%)

Branch coverage included in aggregate %.

4748 of 5526 relevant lines covered (85.92%)

0.86 hits per line

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

62.69
/pacman/model/routing_tables/compressed_multicast_routing_table.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
from pacman.model.routing_tables import AbstractMulticastRoutingTable
1✔
16
from spinn_utilities.overrides import overrides
1✔
17

18

19
class CompressedMulticastRoutingTable(AbstractMulticastRoutingTable):
1✔
20
    """
21
    Represents a compressed routing table for a chip.
22
    """
23

24
    __slots__ = [
1✔
25
        # The x-coordinate of the chip for which this is the routing table
26
        "_x",
27

28
        # The y-coordinate of the chip for which this is the routing tables
29
        "_y",
30

31
        # An iterable of routing entries to add to the table
32
        "_multicast_routing_entries",
33

34
        # counter of how many entries in their multicast routing table are
35
        # defaultable
36
        "_number_of_defaulted_routing_entries"
37
    ]
38

39
    def __init__(self, x, y, multicast_routing_entries=None):
1✔
40
        """
41
        :param int x:
42
            The x-coordinate of the chip for which this is the routing table
43
        :param int y:
44
            The y-coordinate of the chip for which this is the routing tables
45
        :param multicast_routing_entries:
46
            The routing entries to add to the table
47
        :type multicast_routing_entries:
48
            iterable(~spinn_machine.MulticastRoutingEntry)
49
        :raise pacman.exceptions.PacmanAlreadyExistsException:
50
            If any two routing entries contain the same key-mask combination
51
        """
52
        self._x = x
1✔
53
        self._y = y
1✔
54
        self._number_of_defaulted_routing_entries = 0
1✔
55
        self._multicast_routing_entries = list()
1✔
56

57
        if multicast_routing_entries is not None:
1!
58
            for multicast_routing_entry in multicast_routing_entries:
×
59
                self.add_multicast_routing_entry(multicast_routing_entry)
×
60

61
    def add_multicast_routing_entry(self, multicast_routing_entry):
1✔
62
        """
63
        Adds a routing entry to this table.
64

65
        :param ~spinn_machine.MulticastRoutingEntry multicast_routing_entry:
66
            The route to add
67
        :raise pacman.exceptions.PacmanAlreadyExistsException: If a routing
68
            entry with the same key-mask combination already exists
69
        """
70
        self._multicast_routing_entries.append(multicast_routing_entry)
1✔
71

72
        # update default routed counter if required
73
        if multicast_routing_entry.defaultable:
1!
74
            self._number_of_defaulted_routing_entries += 1
×
75

76
    @property
1✔
77
    @overrides(AbstractMulticastRoutingTable.x)
1✔
78
    def x(self):
1✔
79
        return self._x
1✔
80

81
    @property
1✔
82
    @overrides(AbstractMulticastRoutingTable.y)
1✔
83
    def y(self):
1✔
84
        return self._y
1✔
85

86
    @property
1✔
87
    @overrides(AbstractMulticastRoutingTable.multicast_routing_entries)
1✔
88
    def multicast_routing_entries(self):
1✔
89
        return self._multicast_routing_entries
1✔
90

91
    @property
1✔
92
    @overrides(AbstractMulticastRoutingTable.number_of_entries)
1✔
93
    def number_of_entries(self):
1✔
94
        return len(self._multicast_routing_entries)
1✔
95

96
    @property
1✔
97
    @overrides(AbstractMulticastRoutingTable.number_of_defaultable_entries)
1✔
98
    def number_of_defaultable_entries(self):
1✔
99
        return self._number_of_defaulted_routing_entries
×
100

101
    @overrides(AbstractMulticastRoutingTable.__eq__)
1✔
102
    def __eq__(self, other):
1✔
103
        if not isinstance(other, CompressedMulticastRoutingTable):
×
104
            return False
×
105
        if self._x != other.x and self._y != other.y:
×
106
            return False
×
107
        return self._multicast_routing_entries == \
×
108
            other.multicast_routing_entries
109

110
    @overrides(AbstractMulticastRoutingTable.__ne__)
1✔
111
    def __ne__(self, other):
1✔
112
        return not self.__eq__(other)
×
113

114
    @overrides(AbstractMulticastRoutingTable.__repr__)
1✔
115
    def __repr__(self):
1✔
116
        entry_string = ""
×
117
        for entry in self._multicast_routing_entries:
×
118
            entry_string += f"{entry}\n"
×
119
        return f"{self._x}:{self._y}\n\n{entry_string}"
×
120

121
    @overrides(AbstractMulticastRoutingTable.__hash__)
1✔
122
    def __hash__(self):
1✔
123
        return id(self)
×
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