1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+
15+ from types import ModuleType
16+ from typing import List , Optional
1417import numpy
1518import math
16- from spynnaker .pyNN .models .populations import PopulationView
19+ from neo import AnalogSignal
20+ from neo .core .spiketrainlist import SpikeTrainList
21+
22+ from spynnaker .pyNN .models .populations import (Population , PopulationView )
1723
1824
1925class PatternSpiker (object ):
@@ -29,9 +35,12 @@ class PatternSpiker(object):
2935 - 50.73040771484375 , - 50.450927734375 , - 50.185089111328125 ]
3036 V_COUNT = len (V_PATTERN )
3137
32- def create_population (self , sim , n_neurons , label ,
33- spike_rate = None , spike_rec_indexes = None ,
34- v_rate = None , v_rec_indexes = None ):
38+ def create_population (
39+ self , sim : ModuleType , n_neurons : int , label : str ,
40+ spike_rate : Optional [int ] = None ,
41+ spike_rec_indexes : Optional [List [int ]] = None ,
42+ v_rate : Optional [int ] = None ,
43+ v_rec_indexes : Optional [List [int ]] = None ) -> Population :
3544
3645 v_start = self .V_PATTERN * int (math .ceil (n_neurons / self .V_COUNT ))
3746 v_start = v_start [:n_neurons ]
@@ -51,11 +60,13 @@ def create_population(self, sim, n_neurons, label,
5160 view .record (['v' ], sampling_interval = v_rate )
5261 return pop
5362
54- def check_v (self , v , label , v_rate , v_rec_indexes , is_view , missing ):
63+ def check_v (self , v : AnalogSignal , label : str , v_rate : Optional [int ],
64+ v_rec_indexes : Optional [List [int ]], is_view : bool ,
65+ missing : bool ) -> None :
5566 if v_rate is None :
5667 v_rate = 1
5768 if v_rec_indexes is None :
58- v_rec_indexes = range (len (v [0 ]))
69+ v_rec_indexes = list ( range (len (v [0 ]) ))
5970 else :
6071 actual_indexes = list (v .annotations ["channel_names" ])
6172
@@ -85,7 +96,9 @@ def check_v(self, v, label, v_rate, v_rec_indexes, is_view, missing):
8596 self .V_PATTERN [(t + neuron ) % self .V_COUNT ]))
8697
8798 def check_spikes (
88- self , spikes , simtime , label , spike_rate , spike_rec_indexes ):
99+ self , spikes : SpikeTrainList , simtime : int , label : str ,
100+ spike_rate : Optional [int ],
101+ spike_rec_indexes : Optional [List [int ]]) -> None :
89102 for neuron in range (len (spikes )):
90103 if spike_rec_indexes and neuron not in spike_rec_indexes :
91104 continue
@@ -111,8 +124,13 @@ def check_spikes(
111124 "Found {} but expected {}" .format (
112125 neuron , label , spikes [neuron ], adjusted_spikes , ))
113126
114- def check (self , pop , simtime , spike_rate = None , spike_rec_indexes = None ,
115- v_rate = None , v_rec_indexes = None , is_view = False , missing = False ):
127+ def check (
128+ self , pop : Population , simtime : int ,
129+ spike_rate : Optional [int ] = None ,
130+ spike_rec_indexes : Optional [List [int ]] = None ,
131+ v_rate : Optional [int ] = None ,
132+ v_rec_indexes : Optional [List [int ]] = None , is_view : bool = False ,
133+ missing : bool = False ) -> None :
116134 if is_view :
117135 neo = pop .get_data ("spikes" )
118136 spikes = neo .segments [0 ].spiketrains
0 commit comments