@@ -111,25 +111,24 @@ def generate(ref="Example6_PyNN", add_inputs=True):
111111 pop_id = "%s_%s" % (l , t )
112112 pops .append (pop_id )
113113 ref = "l%s%s" % (l [1 :], t .lower ())
114- exec (
115- ref
116- + " = Population(id=pop_id, size='int(%s*N_scaling)'%N_full[l][t], component=cell.id, properties={'color':color, 'type':t})"
117- )
118- exec ( "%s .random_layout = RandomLayout(region = r.id)" % ref )
119- exec ( " net.populations.append(%s)" % ref )
120- exec ( " pop_dict['%s'] = %s" % (pop_id , ref ))
114+ d = {}
115+ d [ ref ] = Population ( id = pop_id , size = 'int(%s*N_scaling)' % N_full [ l ][ t ], component = cell . id , properties = { 'color' : color , 'type' : t })
116+
117+ # Instead of exec, set the attribute directly using locals( )
118+ d [ ref ] .random_layout = RandomLayout (region = r .id )
119+ net .populations .append (d [ ref ] )
120+ pop_dict ['%s' % (pop_id )] = d [ ref ]
121121
122122 if add_inputs :
123123 color = ".8 .8 .8"
124124 input_id = "%s_%s_input" % (l , t )
125125 input_pops .append (input_id )
126126 input_ref = "l%s%s_i" % (l [1 :], t .lower ())
127- exec (
128- input_ref
129- + " = Population(id=input_id, size='int(%s*N_scaling)'%N_full[l][t], component=input_cell.id, properties={'color':color})"
130- )
131- exec ("%s.random_layout = RandomLayout(region = r.id)" % input_ref )
132- exec ("net.populations.append(%s)" % input_ref )
127+ ir = {}
128+ ir [input_ref ] = Population (id = input_id , size = 'int(%s*N_scaling)' % N_full [l ][t ], component = input_cell .id , properties = {'color' :color })
129+
130+ ir [input_ref ].random_layout = RandomLayout (region = r .id )
131+ net .populations .append (ir [input_ref ])
133132
134133 # l23i = Population(id='L23_I', size=int(100*scale), component=cell.id, properties={'color':})
135134 # l23ei = Population(id='L23_E_input', size=int(100*scale), component=input_cell.id)
0 commit comments