Skip to content

Commit

Permalink
Merge pull request #85 from SpiNNakerManchester/size_may_not_be_none
Browse files Browse the repository at this point in the history
rubbered
  • Loading branch information
alan-stokes committed Nov 21, 2017
2 parents be56fdc + d6c857d commit 2fda2ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def __init__(
label=ExternalFPGARetinaDevice.default_parameters['label'],
board_address=ExternalFPGARetinaDevice.default_parameters[
'board_address']):
n_neurons = ExternalFPGARetinaDevice.get_n_neurons(mode, polarity)
DataHolder.__init__(
self, {'spinnaker_link_id': spinnaker_link_id, 'mode': mode,
self, {'n_neurons': n_neurons,
'spinnaker_link_id': spinnaker_link_id, 'mode': mode,
'board_address': board_address, 'label': label,
'retina_key': retina_key, 'polarity': polarity})

Expand Down
19 changes: 17 additions & 2 deletions spynnaker8/models/populations/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from spynnaker.pyNN.utilities.constants import SPIKES
from spinn_front_end_common.utilities import exceptions
from spinn_front_end_common.utilities import globals_variables
from spinn_front_end_common.utilities.exceptions import ConfigurationException

from spynnaker8.models import Recorder
from spynnaker8.utilities import DataHolder
Expand Down Expand Up @@ -33,7 +34,6 @@ def __init__(self, size, cellclass, cellparams=None, structure=None,
vertex_holder.add_item(
'label', self.create_label(
vertex_holder.data_items['label'], label))
vertex_holder.add_item('n_neurons', size)
assert cellparams is None
# cellparams being retained for backwards compatibility, but use
# is deprecated
Expand All @@ -44,13 +44,28 @@ def __init__(self, size, cellclass, cellparams=None, structure=None,
cell_label = internal_params['label']
internal_params['label'] = self.create_label(cell_label, label)
vertex_holder = cellclass(**internal_params)
vertex_holder.add_item('n_neurons', size)
# emit deprecation warning
else:
raise TypeError(
"cellclass must be an instance or subclass of BaseCellType,"
" not a %s" % type(cellclass))

if 'n_neurons' in vertex_holder.data_items:
if size is None:
size = vertex_holder.data_items['n_neurons']
else:
if size != vertex_holder.data_items['n_neurons']:
raise ConfigurationException(
"Size parameter is {} but the {} expects a size of {}"
"".format(size, cellclass,
vertex_holder.data_items['n_neurons']))
else:
if size is None:
raise ConfigurationException(
"Size parameter can not be None for {}".format(cellclass))
else:
vertex_holder.add_item('n_neurons', size)

# convert between data holder and model (uses ** so that its taken
# the dictionary to be the parameters themselves)
vertex = vertex_holder.build_model()(**vertex_holder.data_items)
Expand Down

0 comments on commit 2fda2ac

Please sign in to comment.