FunctionImplementationContainer class

(Shortest import: from brian2.core.functions import FunctionImplementationContainer)

class brian2.core.functions.FunctionImplementationContainer(function)[source]

Bases: _abcoll.Mapping

Helper object to store implementations and give access in a dictionary-like fashion, using CodeGenerator implementations as a fallback for CodeObject implementations.


add_dynamic_implementation(target, code[, …]) Adds an “dynamic implementation” for this function.
add_implementation(target, code[, …])
add_numpy_implementation(wrapped_func[, …]) Add a numpy implementation to a Function.


add_dynamic_implementation(target, code, namespace=None, dependencies=None, name=None)[source]

Adds an “dynamic implementation” for this function. code and namespace arguments are expected to be callables that will be called in Network.before_run() with the owner of the CodeObject as an argument. This allows to generate code that depends on details of the context it is run in, e.g. the dt of a clock.

add_implementation(target, code, namespace=None, dependencies=None, name=None)[source]
add_numpy_implementation(wrapped_func, dependencies=None, discard_units=None)[source]

Add a numpy implementation to a Function.


function : Function

The function description for which an implementation should be added.

wrapped_func : callable

The original function (that will be used for the numpy implementation)

dependencies : list of Function, optional

A list of functions this function needs.

discard_units : bool, optional