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

SpiNNakerManchester / sPyNNaker / 6903208647

17 Nov 2023 11:08AM UTC coverage: 63.17% (+1.6%) from 61.531%
6903208647

Pull #1342

github

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

1961 of 4484 branches covered (0.0%)

Branch coverage included in aggregate %.

4168 of 5102 new or added lines in 234 files covered. (81.69%)

193 existing lines in 78 files now uncovered.

12745 of 18796 relevant lines covered (67.81%)

0.68 hits per line

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

84.09
/spynnaker/pyNN/models/current_sources/abstract_current_source.py
1
# Copyright (c) 2017 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
from enum import Enum
1✔
16
from typing import Mapping, Optional, Sequence, Union, TYPE_CHECKING
1✔
17
from typing_extensions import TypeAlias
1✔
18
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
1✔
19
from spinn_front_end_common.interface.ds import DataType
1✔
20
if TYPE_CHECKING:
21
    from spynnaker.pyNN.models.populations import Population, PopulationBase
22
    from spynnaker.pyNN.models.neuron.abstract_population_vertex import (
23
        AbstractPopulationVertex)
24

25
#: General type of parameters to current sources.
26
#: Individual parameters will only be one of these!
27
CurrentParameter: TypeAlias = Union[int, float, Sequence[int], Sequence[float]]
1✔
28

29

30
# Hashes of the current sources currently supported
31
class CurrentSourceIDs(Enum):
1✔
32
    NO_SOURCE = 0
1✔
33
    DC_SOURCE = 1
1✔
34
    AC_SOURCE = 2
1✔
35
    STEP_CURRENT_SOURCE = 3
1✔
36
    NOISY_CURRENT_SOURCE = 4
1✔
37
    N_SOURCES = 4
1✔
38

39

40
class AbstractCurrentSource(object, metaclass=AbstractBase):
1✔
41
    """
42
    A simplified version of the PyNN class, since in most cases we work
43
    out the actual offset value on the SpiNNaker machine itself based on
44
    the parameters during the run.
45
    """
46
    __slots__ = (
1✔
47
        "__app_vertex",
48
        "__population")
49

50
    def __init__(self) -> None:
1✔
NEW
51
        self.__app_vertex: Optional[AbstractPopulationVertex] = None
×
NEW
52
        self.__population: Optional[Population] = None
×
53

54
    def inject_into(self, cells: PopulationBase):
1✔
55
        """
56
        Inject this source into the specified population cells.
57

58
        :param PopulationBase cells: The cells to inject the source into
59
        """
60
        # Call the population method to pass the source in
61
        cells.inject(self)
×
62

63
    def set_app_vertex(self, vertex: AbstractPopulationVertex):
1✔
64
        """
65
        Set the application vertex associated with the current source.
66

67
        :param AbstractPopulationVertex vertex: The population vertex
68
        """
69
        self.__app_vertex = vertex
×
70

71
    @property
1✔
72
    def app_vertex(self) -> Optional[AbstractPopulationVertex]:
1✔
73
        """
74
        The application vertex associated with the current source.
75

76
        :rtype: AbstractPopulationVertex
77
        """
78
        return self.__app_vertex
×
79

80
    def set_population(self, population: Population):
1✔
81
        """
82
        Set the population associated with the current source.
83

84
        :param ~spynnaker.pyNN.models.populations.Population population:
85
        """
86
        self.__population = population
×
87

88
    @property
1✔
89
    def population(self) -> Optional[Population]:
1✔
90
        """
91
        The population associated with the current source.
92

93
        :rtype: ~spynnaker.pyNN.models.populations.Population
94
        """
95
        return self.__population
×
96

97
    @abstractmethod
1✔
98
    def set_parameters(self, **parameters: CurrentParameter):
1✔
99
        """
100
        Set the current source parameters.
101

102
        :param parameters: the parameters to set
103
        """
104
        raise NotImplementedError
105

106
    @property
1✔
107
    @abstractmethod
1✔
108
    def parameters(self) -> Mapping[str, CurrentParameter]:
1✔
109
        """
110
        The parameters of the current source.
111

112
        :rtype: dict(str, Any)
113
        """
114
        raise NotImplementedError
115

116
    @property
1✔
117
    @abstractmethod
1✔
118
    def parameter_types(self) -> Mapping[str, DataType]:
1✔
119
        """
120
        The parameter types for the current source.
121

122
        :rtype: dict(str, ~.DataType)
123
        """
124
        raise NotImplementedError
125

126
    @property
1✔
127
    @abstractmethod
1✔
128
    def current_source_id(self) -> int:
1✔
129
        """
130
        The ID of the current source.
131

132
        :rtype: int
133
        """
134
        raise NotImplementedError
135

136
    @abstractmethod
1✔
137
    def get_sdram_usage_in_bytes(self) -> int:
1✔
138
        """
139
        The SDRAM usage in bytes of the current source.
140

141
        :rtype: int
142
        """
143
        raise NotImplementedError
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