CodeObject class
(Shortest import: from brian2.codegen.codeobject import CodeObject)
- class brian2.codegen.codeobject.CodeObject(*args, **kw)[source]
Bases:
Nameable
Executable code object.
The
code
can either be a string or abrian2.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
A short name for this type of
CodeObject
The
CodeGenerator
class used by thisCodeObject
Methods
__call__
(**kwds)Call self as a function.
Runs the finalizing code in the namespace.
Runs the preparation code in the namespace.
compile
()compile_block
(block)Whether this target for code generation is available.
run
()Runs the main code in the namespace.
run_block
(block)Update the namespace for this timestep.
Details
- class_name
A short name for this type of
CodeObject
- generator_class
The
CodeGenerator
class used by thisCodeObject
- after_run()[source]
Runs the finalizing code in the namespace. This code will only be executed once per run.
- Returns:
return_value : dict
A dictionary with the keys corresponding to the
output_variables
defined during the call ofCodeGenerator.code_object
.
- before_run()[source]
Runs the preparation code in the namespace. This code will only be executed once per run.
- Returns:
return_value : dict
A dictionary with the keys corresponding to the
output_variables
defined during the call ofCodeGenerator.code_object
.
- classmethod is_available()[source]
Whether this target for code generation is available. Should use a minimal example to check whether code generation works in general.