Skip to content

Commit

Permalink
typing fixes
Browse files Browse the repository at this point in the history
Christian-B committed Jan 20, 2025
1 parent d165579 commit abcba4b
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions spynnaker/plot_utils.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
from types import ModuleType
from typing import Optional
import numpy as np
from numpy.typing import NDArray

# pylint: disable=invalid-name
plt: Optional[ModuleType]
try:
@@ -185,8 +187,7 @@ def plot_spikes(spikes, title="spikes"):
if __name__ == "__main__":
spike_data = np.loadtxt("spikes.csv", delimiter=',')
plot_spikes(spike_data)
doubled_spike_data = np.loadtxt("spikes.csv", delimiter=',')
_i: int
doubled_spike_data: NDArray = np.loadtxt("spikes.csv", delimiter=',')
for _i, doubled_spike_data_i in enumerate(doubled_spike_data):
doubled_spike_data_i[0] = doubled_spike_data[_i][0] + 5
plot_spikes([spike_data, doubled_spike_data])
18 changes: 9 additions & 9 deletions spynnaker/pyNN/models/neuron/population_machine_neurons.py
Original file line number Diff line number Diff line change
@@ -317,7 +317,8 @@ def _write_neuron_core_parameters(
# Write the keys
spec.write_array(keys)

def __in_selector(self, n: int, selector: Selector) -> bool:
def __in_selector(
self, n: Union[int, numpy.integer], selector: Selector) -> bool:
if isinstance(selector, Container):
return n in selector
return n == selector
@@ -363,9 +364,9 @@ def _write_current_source_parameters(
cs_id = current_source.current_source_id

# Only use IDs that are on this core
for i, n in enumerate(self._vertex_slice.get_raster_ids()):
for i, raster_id in enumerate(self._vertex_slice.get_raster_ids()):
if self.__in_selector(
n, current_source_id_list[current_source]):
raster_id, current_source_id_list[current_source]):
# I think this is now right, but test it more...
neuron_current_sources[i][0] += 1
neuron_current_sources[i].append(cs_id)
@@ -378,17 +379,16 @@ def _write_current_source_parameters(

# Now loop over the neurons on this core and write the current
# source ID and index for sources attached to each neuron
for n in range(n_atoms):
n_current_sources = neuron_current_sources[n][0]
for atom in range(n_atoms):
n_current_sources = neuron_current_sources[atom][0]
spec.write_value(n_current_sources)
if n_current_sources != 0:
for csid in range(n_current_sources * 2):
spec.write_value(neuron_current_sources[n][csid+1])
spec.write_value(neuron_current_sources[atom][csid+1])

# Write the number of each type of current source
for n in range(1, len(cs_index_array)):
w = cs_index_array[n]
spec.write_value(w)
for cs_index in range(1, len(cs_index_array)):
spec.write_value(cs_index_array[cs_index])

# Now loop over the current sources and write the data required
# for each type of current source

0 comments on commit abcba4b

Please sign in to comment.