# 2.20. Jupyter / IPython Notebooks¶

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:

1. If you re-run the line from ANNarchy import *, Python will not clear the stored populations and projections (by design, as ANNarchy is already cached)
2. If you re-run a cell creating a population or projection, it will create a new population, not replace the previous one.
3. If you create a new population / projection after a call to 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.