brainpy.core package

ObjType(ST, name, steps[, requires, mode, …])

The base type of neuron and synapse.

NeuType(name, ST, steps[, mode, requires, …])

Abstract Neuron Type.

SynType(name, ST, steps[, mode, requires, …])

Abstract Synapse Type.

Ensemble(name, num, model, monitors, …[, …])

Base Ensemble class.

NeuGroup(model, geometry[, monitors, name, …])

Neuron Group.

SynConn(model[, pre_group, post_group, …])

Synaptic connections.

Network(*args[, mode])

The main simulation controller in BrainPy.

ParsUpdate(all_pars, num, model)

Class for parameter updating.

delayed(func)

Decorator for synapse delay.

class brainpy.core.ObjType(ST, name, steps, requires=None, mode='vector', hand_overs=None)[source]

The base type of neuron and synapse.

Parameters

name (str, optional) – Model name.

class brainpy.core.NeuType(name, ST, steps, mode='vector', requires=None, hand_overs=None)[source]

Abstract Neuron Type.

It can be defined based on a group of neurons or a single neuron.

class brainpy.core.SynType(name, ST, steps, mode='vector', requires=None, hand_overs=None)[source]

Abstract Synapse Type.

It can be defined based on a collection of synapses or a single synapse model.

class brainpy.core.Ensemble(name, num, model, monitors, pars_update, cls_type, satisfies=None)[source]

Base Ensemble class.

Parameters
  • name (str) – Name of the (neurons/synapses) ensemble.

  • num (int) – The number of the neurons/synapses.

  • model (ObjType) – The (neuron/synapse) model.

  • monitors (list, tuple, None) – Variables to monitor.

  • pars_update (dict, None) – Parameters to update.

  • cls_type (str) – Class type.

build(inputs=None, mon_length=0)[source]

Build the object for running.

Parameters
  • inputs (list, tuple) – The object inputs.

  • mon_length (int) – The monitor length.

Returns

calls – The code lines to call step functions.

Return type

list, tuple

get_schedule()[source]

Get the schedule (running order) of the update functions.

Returns

schedule – The running order of update functions.

Return type

list, tuple

run(duration, inputs=(), report=False, report_percent=0.1)[source]

The running function.

Parameters
  • duration (float, int, tuple, list) – The running duration.

  • inputs (list, tuple) – The model inputs with the format of [(key, value [operation])].

  • report (bool) – Whether report the running progress.

  • report_percent (float) – The percent of progress to report.

set_schedule(schedule)[source]

Set the schedule (running order) of the update functions.

For example, if the self.model has two step functions: step1, step2. Then, you can set the shedule by using:

>>> set_schedule(['input', 'step1', 'step2', 'monitor'])
type_checking()[source]

Check the data type needed for step function.

class brainpy.core.NeuGroup(model, geometry, monitors=None, name=None, satisfies=None, pars_update=None)[source]

Neuron Group.

Parameters
  • model (NeuType) – The instantiated neuron type model.

  • geometry (int, tuple) – The neuron group geometry.

  • pars_update (dict) – Parameters to update.

  • monitors (list, tuple) – Variables to monitor.

  • name (str) – The name of the neuron group.

class brainpy.core.SynConn(model, pre_group=None, post_group=None, conn=None, delay=0.0, name=None, monitors=None, satisfies=None, pars_update=None)[source]

Synaptic connections.

Parameters
  • model (SynType) – The instantiated neuron type model.

  • pars_update (dict) – Parameters to update.

  • pre_group (neurons.NeuGroup, neurons.NeuSubGroup) – Pre-synaptic neuron group.

  • post_group (neurons.NeuGroup, neurons.NeuSubGroup) – Post-synaptic neuron group.

  • conn (connectivity.Connector) – Connection method to create synaptic connectivity.

  • num (int) – The number of the synapses.

  • delay (float) – The time of the synaptic delay.

  • monitors (list, tuple) – Variables to monitor.

  • name (str) – The name of the neuron group.

class brainpy.core.Network(*args, mode=None, **kwargs)[source]

The main simulation controller in BrainPy.

Network handles the running of a simulation. It contains a set of objects that are added with add(). The run() method actually runs the simulation. The main loop runs according to user add orders. The objects in the Network are accessible via their names, e.g. net.name would return the object (including neurons and synapses).

add(*args, **kwargs)[source]

Add object (neurons or synapses) to the network.

Parameters
  • args – The nameless objects.

  • kwargs – The named objects, which can be accessed by net.xxx (xxx is the name of the object).

build(run_length, inputs=())[source]

Build the network.

Parameters
  • run_length (int) – The running length.

  • inputs (tuple, list) – The user-defined inputs.

Returns

step_func – The step function.

Return type

callable

run(duration, inputs=(), report=False, report_percent=0.1, data_to_host=False, verbose=True)[source]

Run the simulation for the given duration.

This function provides the most convenient way to run the network. For example:

Parameters
  • duration (int, float, tuple, list) – The amount of simulation time to run for.

  • inputs (list, tuple) – The receivers, external inputs and durations.

  • report (bool) – Report the progress of the simulation.

  • report_percent (float) – The speed to report simulation progress.

  • data_to_host (bool) – Transfer the gpu data to cpu. Available in CUDA backend.

  • verbose (bool) – Show the error information.

class brainpy.core.ParsUpdate(all_pars, num, model)[source]

Class for parameter updating.

Structure of ParsUpdate

  • origins : original parameters

  • num : number of the neurons

  • updates : parameters to update

  • heters : parameters to update, and they are heterogeneous

  • model : the model which this ParsUpdate belongs to

get(item)[source]

Get the parameter value by its key.

Parameters

item (str) – Parameter name.

Returns

value – Parameter value.

Return type

any

items()[source]

All parameters, including keys and values.

Returns

items – The iterable parameter items.

Return type

iterable

keys()[source]

All parameters can be updated.

Returns

keys – List of parameter names.

Return type

list