Dear Helge and Julien,
I recently started using ANNarchy. Thank you for the great work. It is very easy to get started, and the documentation is fantastic.
There is one beginner's question I am stuck on, and I hope you can set me on the right path:
I would like to create my network object inside a function, return it and use it outside the function. I used the following to construct the network and assumed this would work. However, it seems the network objects are not contained within net as expected.
net = Network(everything=True)
Below is a simple example of what I would like to do. It fails because the monitor I am trying to access in the last line is unknown (NameError: name 'm' is not defined).
def build_model():
input_pop = Population(1, Neuron(parameters="r=10.0"))
pop1 = Population(1, LeakyIntegrator)
proj = Projection(input_pop, pop1, 'exc')
proj.connect_all_to_all(1.0)
m = Monitor(pop1, 'r')
net = Network(everything=True)
return net # return net, input_pop, pop1, proj, m
net = build_model() # net, input_pop, pop1, proj, m = build_model()
net.compile()
net.simulate(10.0)
print(net.get(m).get('r'))
The solution I found is commented out. I am not sure if maybe I'm overlooking a better solution. I am using the constructor wrong?
Thanks for the heads up
Emma