CodeObject class

(Shortest import: from brian2 import CodeObject)

class brian2.codegen.codeobject.CodeObject(owner, code, variables, name='codeobject*')[source]

Bases: brian2.core.names.Nameable

Executable code object.

The code can either be a string or a brian2.codegen.templates.MultiTemplate.

After initialisation, the code is compiled with the given namespace using code.compile(namespace).

Calling code(key1=val1, key2=val2) executes the code with the given variables inserted into the namespace.

Attributes

class_name A short name for this type of CodeObject
generator_class The CodeGenerator class used by this CodeObject

Methods

__call__(**kwds)
compile()
run() Runs the code in the namespace.
update_namespace() Update the namespace for this timestep.

Details

class_name

A short name for this type of CodeObject

generator_class

The CodeGenerator class used by this CodeObject

__call__(**kwds)[source]
compile()[source]
run()[source]

Runs the code in the namespace.

Returns:

return_value : dict

A dictionary with the keys corresponding to the output_variables defined during the call of CodeGenerator.code_object.

update_namespace()[source]

Update the namespace for this timestep. Should only deal with variables where the reference changes every timestep, i.e. where the current reference in namespace is not correct.