from brian2 import analyse_identifiers)
analyse_identifiers(code, variables, recursive=False)¶
Analyses a code string (sequence of statements) to find all identifiers by type.
In a given code block, some variable names (identifiers) must be given as inputs to the code block, and some are created by the code block. For example, the line:
a = b+c
This could mean to create a new variable a from b and c, or it could mean modify the existing value of a from b or c, depending on whether a was previously known.
code : str
The code string, a sequence of statements one per line.
variables : dict of
Variable, set of names
Specifiers for the model variables or a set of known names
recursive : bool, optional
Whether to recurse down into subexpressions (defaults to
newly_defined : set
A set of variables that are created by the code block.
used_known : set
A set of variables that are used and already known, a subset of the
unknown : set
A set of variables which are used by the code block but not defined by it and not previously known. Should correspond to variables in the external namespace.