from brian2.codegen.translation import make_statements)
make_statements(code, variables, dtype, optimise=True, blockname='')¶
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
The data type to use for temporary variables
optimise : bool, optional
Whether to optimise expressions, including pulling out loop invariant expressions and putting them in new scalar constants. Defaults to
False, since this function is also used just to in contexts where we are not interested by this kind of optimisation. For the main code generation stage, its value is set by the codegen.loop_invariant_optimisations preference.
blockname : str, optional
A name for the block (used to name intermediate variables to avoid name clashes when multiple blocks are used together)
scalar_statements, vector_statements : (list of
Statement, list of
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)
True, then the
scalar_statementsmay 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 + 1will be replaced by
w += 1. Also, statements involving booleans will have additional information added to them (see
Statementfor details) describing how the statement can be reformulated as a sequence of if/then statements. Calls