Skip to content

Commit f96be63

Browse files
author
Andrew Davison
committed
Fixed (?) an inconsistency in pyNN.brian
1 parent 2a5ba7a commit f96be63

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

pyNN/brian/projections.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pyNN import common
1212
from pyNN.standardmodels.synapses import TsodyksMarkramSynapse
1313
from pyNN.core import is_listlike
14+
from .populations import PopulationView
1415
from pyNN.parameters import ParameterSpace
1516
from pyNN.space import Space
1617
from . import simulator
@@ -139,7 +140,7 @@ def _partition(self, indices):
139140
else:
140141
partitions = [indices]
141142
return partitions
142-
143+
143144
def _localize_index(self, index):
144145
"""determine which group the postsynaptic index belongs to """
145146
if isinstance(self.post, common.Assembly):
@@ -192,7 +193,7 @@ def _set_attributes(self, connection_parameters):
192193
value = value.T
193194
filtered_value = value[syn_obj.postsynaptic, syn_obj.presynaptic]
194195
setattr(syn_obj, name, filtered_value)
195-
196+
196197
def _get_attributes_as_arrays(self, attribute_names, multiple_synapses='sum'):
197198
if isinstance(self.post, common.Assembly) or isinstance(self.pre, common.Assembly):
198199
raise NotImplementedError
@@ -215,8 +216,12 @@ def _get_attributes_as_list(self, attribute_names):
215216
for name in attribute_names:
216217
if name == "presynaptic_index":
217218
value = self._brian_synapses[0][0].presynaptic
219+
if isinstance(self.pre, PopulationView):
220+
value = self.pre.id_to_index(value)
218221
elif name == "postsynaptic_index":
219222
value = self._brian_synapses[0][0].postsynaptic
223+
if isinstance(self.post, PopulationView):
224+
value = self.post.id_to_index(value)
220225
else:
221226
data_obj = getattr(self._brian_synapses[0][0], name).data
222227
if hasattr(data_obj, "tolist"):

test/system/scenarios/test_connectors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def issue622(sim):
206206
sim.setup()
207207
pop = sim.Population(10, sim.IF_cond_exp, {}, label="pop")
208208

209-
view1 = sim.PopulationView(pop , [2,3,4])
210-
view2 = sim.PopulationView(pop , [2,3,4])
209+
view1 = sim.PopulationView(pop, [2,3,4])
210+
view2 = sim.PopulationView(pop, [2,3,4])
211211

212212
proj1 = sim.Projection(view1, view2, sim.AllToAllConnector(allow_self_connections = False), sim.StaticSynapse(
213213
weight=0.015, delay=1.0), receptor_type='excitatory')

0 commit comments

Comments
 (0)