Skip to content

Commit b376025

Browse files
committed
changes to please mypy
1 parent 0693edd commit b376025

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

spynnaker/pyNN/external_devices/__init__.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def EthernetControlPopulation(
207207
local_host: Optional[str] = None, local_port: Optional[int] = None,
208208
database_notify_port_num: Optional[int] = None,
209209
database_ack_port_num: Optional[int] = None,
210+
n_synapse_cores: Optional[int] = None,
210211
**additional_kwargs: Dict[str, Any]) -> Population:
211212
# pylint: disable=invalid-name
212213
"""
@@ -227,8 +228,13 @@ def EthernetControlPopulation(
227228
:param database_notify_port_num:
228229
The optional port to which notifications from the database
229230
notification protocol are to be sent
231+
:param n_synapse_cores: Typed semantic sugar for an additional_kwargs
230232
:param additional_kwargs:
231-
A nicer way of allowing additional things to the Population
233+
Additional parameters to pass to the vertex creation function.
234+
See the Model's create_vertex method for more details.
235+
These will be ignored if the Model does not accept this parameter.
236+
These will raise an Exception if a Vertex is passed in
237+
There may be additional parameters not listed in this init.
232238
:return:
233239
A pyNN Population which can be used as the target of a Projection.
234240
@@ -237,9 +243,14 @@ def EthernetControlPopulation(
237243
Projection, but it might not send spikes.
238244
:raises TypeError: If an invalid model class is used.
239245
"""
246+
additional: Dict[str, Any] = dict()
247+
if additional_kwargs:
248+
additional.update(additional_kwargs)
249+
if n_synapse_cores is not None:
250+
additional['n_synapse_cores'] = n_synapse_cores
240251
# pylint: disable=global-statement
241252
population = Population(n_neurons, model, label=label,
242-
**additional_kwargs)
253+
additional_parameters=additional)
243254
vertex, aec, vertex_label = __vtx(population)
244255
translator = aec.get_message_translator()
245256
live_packet_gather_label = "EthernetControlReceiver"
@@ -306,13 +317,13 @@ def EthernetSensorPopulation(
306317
if not isinstance(device, AbstractEthernetSensor):
307318
raise TypeError(
308319
"Device must be an instance of AbstractEthernetSensor")
309-
injector_params = dict(device.get_injector_parameters())
310-
320+
additional_parameters = dict(device.get_injector_parameters())
321+
if additional_kwargs:
322+
additional_parameters.update(additional_kwargs)
311323
population = Population(
312324
device.get_n_neurons(), SpikeInjector(notify=False),
313325
label=device.get_injector_label(),
314-
additional_parameters=injector_params,
315-
**additional_kwargs)
326+
additional_parameters=additional_parameters)
316327
if isinstance(device, AbstractSendMeMulticastCommandsVertex):
317328
cmd_conn = EthernetCommandConnection(
318329
device.get_translator(), [device], local_host,

spynnaker/pyNN/models/populations/population.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def __init__(
8686
structure: Optional[BaseStructure] = None,
8787
initial_values: Optional[Dict[str, float]] = None,
8888
label: Optional[str] = None,
89-
max_rate: Optional[float] = None,
89+
*, max_rate: Optional[float] = None,
9090
n_colour_bits: Optional[int] = None,
91+
n_synapse_cores: Optional[int] = None,
9192
neurons_per_core: Optional[Union[int, Tuple[int, ...]]] = None,
9293
port: Optional[int] = None,
9394
reserve_reverse_ip_tag: Optional[bool] = None,
@@ -107,6 +108,7 @@ def __init__(
107108
:param label: A label for the population
108109
:param max_rate: Typed semantic sugar for an additional_parameter
109110
:param n_colour_bits: Typed semantic sugar for an additional_parameter
111+
:param n_synapse_cores: Typed semantic sugar for an additional_parameter
110112
:param neurons_per_core:
111113
Typed semantic sugar for an additional_parameter
112114
:param port: Typed semantic sugar for an additional_parameter
@@ -137,6 +139,8 @@ def __init__(
137139
additional['max_rate'] = max_rate
138140
if n_colour_bits is not None:
139141
additional['n_colour_bits'] = n_colour_bits
142+
if n_synapse_cores is not None:
143+
additional['n_synapse_cores'] = n_synapse_cores
140144
if neurons_per_core is not None:
141145
additional['neurons_per_core'] = neurons_per_core
142146
if port is not None:

0 commit comments

Comments
 (0)