make_statements function

(Shortest import: from brian2 import make_statements)

brian2.codegen.translation.make_statements(code, variables, dtype)[source]

Turn a series of abstract code statements into Statement objects, inferring whether each line is a set/declare operation, whether the variables are constant or not, and handling the cacheing of subexpressions.


code : str

A (multi-line) string of statements.

variables : dict-like

A dictionary of with Variable and Function objects for every identifier used in the code.

dtype : dtype

The data type to use for temporary variables


scalar_statements, vector_statements : (list of Statement, list of Statement)

Lists with statements that are to be executed once and statements that are to be executed once for every neuron/synapse/... (or in a vectorised way)


The scalar_statements may include newly introduced scalar constants that have been identified as loop-invariant and have therefore been pulled out of the vector statements. The resulting statements will also use augmented assignments where possible, i.e. a statement such as w = w + 1 will be replaced by w += 1.