Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n_neurons from other parameters #85

Merged
merged 1 commit into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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