brainpy.core package

ObjType(name, ST, steps, List, Tuple], …)

The base type of neuron and synapse.

NeuType(name, ST, steps, List, Tuple], mode, …)

Abstract Neuron Type.

SynType(name, ST, steps, list, tuple], mode, …)

Abstract Synapse Type.

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

Base Ensemble class.

NeuGroup(model, geometry, List, int], …)

Neuron Group.

SynConn(model, pre_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(name: str, ST: brainpy.core.types.ObjState, steps: Union[Callable, List, Tuple], requires: Optional[Dict] = None, mode: str = 'vector', heter_params_replace: Optional[Dict] = None, extra_functions: Union[List, Tuple] = (), extra_attributes: Optional[Dict[str, Any]] = None)[source]

The base type of neuron and synapse.

Parameters

name (str, optional) – Model name.

class brainpy.core.NeuType(name: str, ST: brainpy.core.types.NeuState, steps: Union[Callable, List, Tuple], mode: str = 'vector', requires: Optional[dict] = None, heter_params_replace: Optional[Dict] = None, extra_functions: Union[List, Tuple] = (), extra_attributes: Optional[Dict[str, Any]] = None)[source]

Abstract Neuron Type.

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

class brainpy.core.SynType(name: str, ST: brainpy.core.types.SynState, steps: Union[callable, list, tuple], mode: str = 'vector', requires: Optional[dict] = None, heter_params_replace: Optional[dict] = None, extra_functions: Union[List, Tuple] = (), extra_attributes: Optional[Dict[str, Any]] = 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: str, num: int, model: brainpy.core.base.ObjType, monitors: Tuple, pars_update: Dict, cls_type: str)[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.

class brainpy.core.NeuGroup(model: brainpy.core.neurons.NeuType, geometry: Union[Tuple, List, int], pars_update: Optional[Dict] = None, monitors: Optional[Union[List, Tuple]] = None, name: Optional[str] = None, **kwargs)[source]

Neuron Group.

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

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

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

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

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

class brainpy.core.SynConn(model: brainpy.core.synapses.SynType, pre_group: Optional[Union[brainpy.core.neurons.NeuGroup, brainpy.core.neurons.NeuSubGroup]] = None, post_group: Optional[Union[brainpy.core.neurons.NeuGroup, brainpy.core.neurons.NeuSubGroup]] = None, conn: Optional[Union[brainpy.connectivity.base.Connector, numpy.ndarray, Dict]] = None, pars_update: Optional[Dict] = None, delay: float = 0.0, monitors: Optional[Union[List, Tuple]] = None, name: Optional[str] = None, **kwargs: Any)[source]

Synaptic connections.

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

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

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

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

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

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

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

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

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

class brainpy.core.Network(*args, mode='once', **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 or monitor) 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).

run(duration, inputs=(), report=False, report_percent=0.1)[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.

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