Skip to content

Commit 5269f06

Browse files
committed
Merge branch 'master' into spike_filter
2 parents 8669a19 + e3aa95f commit 5269f06

27 files changed

Lines changed: 419 additions & 62 deletions

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ install_requires =
5252
lazyarray
5353
# below may fail for read the docs
5454
csa
55+
h5py != 3.16.0;platform_system=='Windows'
5556

5657
[options.packages.find]
5758
include =

spynnaker/pyNN/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
PoolDenseConnector)
7575
# synapse structures
7676
from spynnaker.pyNN.models.neuron.synapse_dynamics import (
77-
AbstractStaticSynapseDynamics,
7877
SynapseDynamicsStatic as StaticSynapse)
7978

8079
# plastic stuff
@@ -149,6 +148,8 @@
149148

150149
# big stuff
151150
from spynnaker.pyNN.spinnaker import SpiNNaker
151+
from spynnaker.pyNN.models.neuron.synapse_dynamics import (
152+
AbstractSynapseDynamics)
152153

153154
from spynnaker._version import __version__ # NOQA
154155
from spynnaker._version import __version_name__ # NOQA
@@ -357,7 +358,7 @@ def Projection(
357358
presynaptic_population: Population,
358359
postsynaptic_population: Population,
359360
connector: AbstractConnector,
360-
synapse_type: Optional[AbstractStaticSynapseDynamics] = None,
361+
synapse_type: Optional[AbstractSynapseDynamics] = None,
361362
source: None = None, receptor_type: str = "excitatory",
362363
space: Optional[Space] = None, label: Optional[str] = None,
363364
download_synapses: bool = False,

spynnaker/pyNN/config_setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
fec_cfg_paths_skipped)
2323

2424
from spynnaker.pyNN.data.spynnaker_data_writer import SpynnakerDataWriter
25+
from spynnaker.pyNN.models.neuron import AbstractPyNNNeuronModel
2526

2627
SPYNNAKER_CFG = "spynnaker.cfg"
2728

@@ -43,6 +44,7 @@ def unittest_setup() -> None:
4344
clear_cfg_files(True)
4445
add_spynnaker_cfg()
4546
SpynnakerDataWriter.mock()
47+
AbstractPyNNNeuronModel.reset_all()
4648

4749

4850
def add_spynnaker_cfg() -> None:

spynnaker/pyNN/external_devices/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
accuracy to gain performance.
2222
"""
2323
import os
24-
from typing import Optional, Tuple
24+
from typing import Any, Dict, Optional, Tuple
2525
from spinn_utilities.socket_address import SocketAddress
2626
from spinnman.messages.eieio import EIEIOType
2727
from spinn_front_end_common.abstract_models import (
@@ -206,7 +206,8 @@ def EthernetControlPopulation(
206206
n_neurons: int, model: _CellTypeArg, label: Optional[str] = None,
207207
local_host: Optional[str] = None, local_port: Optional[int] = None,
208208
database_notify_port_num: Optional[int] = None,
209-
database_ack_port_num: Optional[int] = None) -> Population:
209+
database_ack_port_num: Optional[int] = None,
210+
**additional_kwargs: Dict[str, Any]) -> Population:
210211
# pylint: disable=invalid-name
211212
"""
212213
Create a PyNN population that can be included in a network to
@@ -226,6 +227,8 @@ def EthernetControlPopulation(
226227
:param database_notify_port_num:
227228
The optional port to which notifications from the database
228229
notification protocol are to be sent
230+
:param additional_kwargs:
231+
A nicer way of allowing additional things to the Population
229232
:return:
230233
A pyNN Population which can be used as the target of a Projection.
231234
@@ -235,7 +238,8 @@ def EthernetControlPopulation(
235238
:raises TypeError: If an invalid model class is used.
236239
"""
237240
# pylint: disable=global-statement
238-
population = Population(n_neurons, model, label=label)
241+
population = Population(n_neurons, model, label=label,
242+
**additional_kwargs)
239243
vertex, aec, vertex_label = __vtx(population)
240244
translator = aec.get_message_translator()
241245
live_packet_gather_label = "EthernetControlReceiver"
@@ -273,7 +277,8 @@ def EthernetControlPopulation(
273277
def EthernetSensorPopulation(
274278
device: AbstractEthernetSensor, local_host: Optional[str] = None,
275279
database_notify_port_num: Optional[int] = None,
276-
database_ack_port_num: Optional[int] = None) -> Population:
280+
database_ack_port_num: Optional[int] = None,
281+
**additional_kwargs: Dict[str, Any]) -> Population:
277282
# pylint: disable=invalid-name
278283
"""
279284
Create a pyNN population which can be included in a network to
@@ -289,6 +294,8 @@ def EthernetSensorPopulation(
289294
:param database_notify_port_num:
290295
The optional port to which notifications from the database
291296
notification protocol are to be sent
297+
:param additional_kwargs:
298+
A nicer way of allowing additional things to the Population
292299
:return:
293300
A pyNN Population which can be used as the source of a Projection.
294301
@@ -304,7 +311,8 @@ def EthernetSensorPopulation(
304311
population = Population(
305312
device.get_n_neurons(), SpikeInjector(notify=False),
306313
label=device.get_injector_label(),
307-
additional_parameters=injector_params)
314+
additional_parameters=injector_params,
315+
**additional_kwargs)
308316
if isinstance(device, AbstractSendMeMulticastCommandsVertex):
309317
cmd_conn = EthernetCommandConnection(
310318
device.get_translator(), [device], local_host,

spynnaker/pyNN/models/abstract_pynn_model.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class AbstractPyNNModel(AbstractProvidesDefaults, metaclass=AbstractBase):
4040
_max_atoms_per_core: Dict[type, Optional[Tuple[int, ...]]] = defaultdict(
4141
lambda: None)
4242

43+
_model_created = False
44+
45+
# Using new as most super classes do not call the init
46+
def __new__(cls, *args: Any, **kwargs: Any) -> "AbstractPyNNModel":
47+
_ = (args, kwargs)
48+
AbstractPyNNModel._model_created = True
49+
return super(AbstractPyNNModel, cls).__new__(cls)
50+
4351
@classmethod
4452
def verify_may_set(cls, param: str) -> None:
4553
""" If a Population has been created, this method will raise an
@@ -51,13 +59,18 @@ def verify_may_set(cls, param: str) -> None:
5159
in the Population constructor instead.
5260
"""
5361
SpynnakerDataView.check_user_can_act()
54-
if SpynnakerDataView.get_n_populations() == 0:
55-
return
56-
raise SpynnakerException(
57-
"Global set is not supported after a Population has been "
58-
"created. Either move it above the creation of all Populations "
59-
f"or provide {param} during the creation of each Population it "
60-
"applies to.")
62+
if SpynnakerDataView.get_n_populations() > 0:
63+
raise SpynnakerException(
64+
"Global set is not supported after a Population has been "
65+
"created. Either move it above the creation of all "
66+
f"Populations or provide {param} during the creation of each "
67+
"Population it applies to.")
68+
if AbstractPyNNModel._model_created:
69+
raise SpynnakerException(
70+
"Global set is not supported after a Model has been "
71+
"created. Either move it above the creation of all "
72+
f"Models or provide {param} during the creation of each "
73+
"Population it applies to.")
6174

6275
@classmethod
6376
def set_model_max_atoms_per_dimension_per_core(
@@ -115,6 +128,7 @@ def reset_all(cls) -> None:
115128
Reset the maximum values for all classes.
116129
"""
117130
AbstractPyNNModel._max_atoms_per_core.clear()
131+
AbstractPyNNModel._model_created = False
118132

119133
@classproperty
120134
def absolute_max_atoms_per_core( # pylint: disable=no-self-argument

spynnaker/pyNN/models/neuron/plasticity/stdp/weight_dependence/weight_dependence_additive.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ def write_parameters(
104104
data=self.__w_max * global_weight_scale,
105105
data_type=DataType.S1615)
106106

107-
# pylint: disable=wrong-spelling-in-comment
108-
# Based on http://data.andrewdavison.info/docs/PyNN/_modules/pyNN
109-
# /standardmodels/synapses.html
110-
# Pre-multiply A+ and A- by Wmax
111107
spec.write_value(
112108
data=self.A_plus * global_weight_scale,
113109
data_type=DataType.S1615)

spynnaker/pyNN/models/neuron/plasticity/stdp/weight_dependence/weight_dependence_additive_triplet.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ def write_parameters(
127127
spec.write_value(data=self.__w_max * global_weight_scale,
128128
data_type=DataType.S1615)
129129

130-
# pylint: disable=wrong-spelling-in-comment
131-
# Based on http://data.andrewdavison.info/docs/PyNN/_modules/pyNN
132-
# /standardmodels/synapses.html
133-
# Pre-multiply A+ and A- by Wmax
134130
spec.write_value(
135131
data=self.A_plus * self.__w_max * global_weight_scale,
136132
data_type=DataType.S1615)

spynnaker/pyNN/models/neuron/population_vertex.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,8 @@ def combined_binary_exists(self) -> bool:
523523
# so easier to assume they exist
524524
if get_config_bool("Machine", "virtual_board"):
525525
return True
526-
try:
527-
SpynnakerDataView().get_executable_path(
528-
self.combined_binary_file_name)
529-
return True
530-
except KeyError:
531-
return False
526+
return SpynnakerDataView().check_executable_path(
527+
self.combined_binary_file_name)
532528

533529
@property
534530
def split_binaries_exist(self) -> bool:
@@ -539,14 +535,11 @@ def split_binaries_exist(self) -> bool:
539535
# so easier to assume they exist
540536
if get_config_bool("Machine", "virtual_board"):
541537
return True
542-
try:
543-
SpynnakerDataView().get_executable_path(
544-
self.neuron_core_binary_file_name)
545-
SpynnakerDataView().get_executable_path(
546-
self.synapse_core_binary_file_name)
547-
return True
548-
except KeyError:
538+
if not SpynnakerDataView().check_executable_path(
539+
self.neuron_core_binary_file_name):
549540
return False
541+
return SpynnakerDataView().check_executable_path(
542+
self.synapse_core_binary_file_name)
550543

551544
@property
552545
def use_combined_core(self) -> bool:

spynnaker/pyNN/models/neuron/synapse_dynamics/synapse_dynamics_structural_static.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def set_connections(
212212
if not isinstance(synapse_info.synapse_dynamics,
213213
AbstractSynapseDynamicsStructural):
214214
return
215+
self.__connections = dict()
215216
collector = self.__connections.setdefault(
216217
(app_edge.post_vertex, post_vertex_slice.lo_atom), [])
217218
collector.append((connections, app_edge, synapse_info))

spynnaker/pyNN/models/neuron/synapse_dynamics/synapse_dynamics_structural_stdp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def set_connections(
223223
if not isinstance(synapse_info.synapse_dynamics,
224224
AbstractSynapseDynamicsStructural):
225225
return
226+
self.__connections = dict()
226227
collector = self.__connections.setdefault(
227228
(app_edge.post_vertex, post_vertex_slice.lo_atom), [])
228229
collector.append((connections, app_edge, synapse_info))

0 commit comments

Comments
 (0)