Utility classes and functions

init_logging(logfile, debug=False, num_processes=1, rank=0, level=None)[source]

Simple configuration of logging.

get_simulator(*arguments)[source]

Import and return a PyNN simulator backend module based on command-line arguments.

The simulator name should be the first positional argument. If your script needs additional arguments, you can specify them as (name, help_text) tuples. If you need more complex argument handling, you should use argparse directly.

Returns (simulator, command-line arguments)

class Timer[source]

For timing script execution.

Timing starts on creation of the timer.

start()[source]

Start/restart timing.

elapsed_time(format=None)[source]

Return the elapsed time in seconds but keep the clock running.

If called with format="long", return a text representation of the time. Examples:

>>> timer.elapsed_time()
987
>>> timer.elapsed_time(format='long')
16 minutes, 27 seconds
elapsedTime(**kwargs)

Deprecated. Use elapsed_time() instead.

reset()[source]

Reset the time to zero, and start the clock.

diff(format=None)[source]

Return the time since the last time elapsed_time() or diff() was called.

If called with format='long', return a text representation of the time.

static time_in_words(s)[source]

Formats a time in seconds as a string containing the time in days, hours, minutes, seconds. Examples:

>>> Timer.time_in_words(1)
1 second
>>> Timer.time_in_words(123)
2 minutes, 3 seconds
>>> Timer.time_in_words(24*3600)
1 day
mark(label)[source]

Store the time since the last time since the last time elapsed_time(), diff() or mark() was called, together with the provided label, in the attribute ‘marks’.

class ProgressBar(width=77, char='#', mode='fixed')[source]

Create a progress bar in the shell.

set_level(level)[source]

Rebuild the bar string based on level, which should be a number between 0 and 1.

notify(msg='Simulation finished.', subject='Simulation finished.', smtphost=None, address=None)[source]

Send an e-mail stating that the simulation has finished.

save_population(population, filename, variables=None)[source]

Saves the spike_times of a population and the size, structure, labels such that one can load it back into a SpikeSourceArray population using the load_population() function.

load_population(filename, sim)[source]

Loads a population that was saved with the save_population() function into SpikeSourceArray.

Basic plotting