• 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

42.5
/spinnman/model/heap_element.py
1
# Copyright (c) 2016 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 Optional
1✔
15

16

17
class HeapElement(object):
1✔
18
    """
19
    An element of one of the heaps on SpiNNaker.
20
    """
21

22
    __slots__ = [
1✔
23
        # A pointer to the block
24
        "_block_address",
25
        # A pointer to the next block
26
        "_next_address",
27
        # True if the block is free
28
        "_is_free",
29
        # The tag of the block
30
        "_tag",
31
        # The app ID of the block
32
        "_app_id"
33
    ]
34

35
    def __init__(self, block_address: int, next_address: int, free: int):
1✔
36
        """
37
        :param int block_address: The address of this element on the heap
38
        :param int next_address: The address of the next element on the heap
39
        :param int free: The "free" element of the block as read from the heap
40
        """
41
        self._block_address = block_address
×
42
        self._next_address = next_address
×
43
        self._is_free = (free & 0xFFFF0000) != 0xFFFF0000
×
44
        self._tag: Optional[int] = None
×
45
        self._app_id: Optional[int] = None
×
46
        if not self._is_free:
×
47
            self._tag = free & 0xFF
×
48
            self._app_id = (free >> 8) & 0xFF
×
49

50
    @property
1✔
51
    def block_address(self) -> int:
1✔
52
        """
53
        The address of the block.
54

55
        :rtype: int
56
        """
57
        return self._block_address
×
58

59
    @property
1✔
60
    def next_address(self) -> int:
1✔
61
        """
62
        The address of the next block, or 0 if none.
63

64
        :rtype: int
65
        """
66
        return self._next_address
×
67

68
    @property
1✔
69
    def size(self) -> int:
1✔
70
        """
71
        The usable size of this block (not including the header).
72

73
        :rtype: int
74
        """
75
        return self._next_address - self._block_address - 8
×
76

77
    @property
1✔
78
    def is_free(self) -> bool:
1✔
79
        """
80
        Whether this block is a free block.
81

82
        :rtype: bool
83
        """
84
        return self._is_free
×
85

86
    @property
1✔
87
    def tag(self) -> Optional[int]:
1✔
88
        """
89
        The tag of the block if allocated, or `None` if not.
90

91
        :rtype: int or None
92
        """
93
        return self._tag
×
94

95
    @property
1✔
96
    def app_id(self) -> Optional[int]:
1✔
97
        """
98
        The application ID of the block if allocated, or `None` if not.
99

100
        :rtype: int or None
101
        """
102
        return self._app_id
×
103

104
    def __str__(self) -> str:
1✔
105
        if self._is_free:
×
106
            return "FREE  0x{:8X} SIZE: {:9d}".format(
×
107
                self._block_address, self.size)
108
        assert self._tag is not None
×
109
        assert self._app_id is not None
×
110
        return "BLOCK 0x{:8X} SIZE: {:9d} TAG: {:3d} APP_ID: {:3d}".format(
×
111
            self._block_address, self.size, self._tag, self._app_id)
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