Python-standalone target

NESTML features supported: neurons

The aim of the Python-standalone target is to facilitate model development and debugging. The generated Python code is intended to be easy to read and understand, rather than to be fast. When satisfied with the Python target results, high-performance code can then be generated by simply switching to a different target platform.

A Python class is generated for each neuron, as well as a very simple simulator that applies some spikes to the model(s) and measures the results. This generated code can be run independently of any installed simulator (only a few common Python packages are required, like scipy for numerical integration). The following files are generated in the target directory:

File

Description

<neuron_name>.py

Generated code for the neuron model.

neuron.py

Abstract base class for neurons.

simulator.py

A very simple simulator that can be used to instantiate neurons and spike generators, make connections between them, and perform time stepping of the network.

spike_generator.py

Can be used to emit spikes at predefined points in time.

test_python_standalone_module.py

Runnable test file that instantiates the network, runs a simulation, and plots the results.

utils.py

Miscellaneous utility functions.

After the code has been generated, a simple test can can be run by calling:

python3 test_python_standalone_module.py

Code generation options

Several code generator options are available; for an overview see pynestml.codegeneration.python_standalone_code_generator.PythonStandaloneCodeGenerator.