It is possible to use ANNarchy in Jupyter / IPython notebooks. Several
examples are provided in the examples
directory of the source
distribution.
There is nevertheless one thing to take into account when re-running cells:
ANNarchy uses global variables to store the populations and projections until compile() is called.
Here are the main consequences:
from ANNarchy import *
, Python will not
clear the stored populations and projections (by design, as ANNarchy
is already cached)compile()
in the current kernel, this will lead to an error, as
the network is already compiled and new objects cannot (yet) be added
on the fly.The solution to the first problem is to call the clear()
command
right after importing ANNarchy. This deletes all created objects and
puts ANNarchy in a “clean” state:
In [1]:
from ANNarchy import *
clear()
ANNarchy 4.6 (4.6.0b) on linux (posix).
Everytime you want to change something to the structure of your network
(adding/suppressing a population or projection, changing the size of a
population or modifying a connection pattern), you can re-run this cell,
as well as all cells defining your network. You will then be able to
call compile()
again.
If you only want to change some parameters, you do not need to run this cell.