brian_ast function

(Shortest import: from brian2.parsing.bast import brian_ast)

brian2.parsing.bast.brian_ast(expr, variables)[source]

Returns an AST tree representation with additional information

Each node will be a standard Python ast node with the following additional attributes:

dtype

One of 'boolean', 'integer' or 'float', referring to the data type of the value of this node.

scalar

Either True or False if the node uses any vector-valued variables.

complexity

An integer representation of the computational complexity of the node. This is a very rough representation used for things like 2*(x+y) is less complex than 2*x+2*y and exp(x) is more complex than 2*x but shouldn’t be relied on for fine distinctions between expressions.