ArithmeticSimplifier class

(Shortest import: from brian2.codegen.optimisation import ArithmeticSimplifier)

class brian2.codegen.optimisation.ArithmeticSimplifier(variables)[source]

Bases: BrianASTRenderer

Carries out the following arithmetic simplifications:

  1. Constant evaluation (e.g. exp(0)=1) by attempting to evaluate the expression in an “assumptions namespace”

  2. Binary operators, e.g. 0*x=0, 1*x=x, etc. You have to take care that the dtypes match here, e.g. if x is an integer, then 1.0*x shouldn’t be replaced with x but left as 1.0*x.

Methods

render_BinOp(node)

render_node(node)

Assumes that the node has already been fully processed by BrianASTRenderer

Details

render_BinOp(node)[source]
render_node(node)[source]

Assumes that the node has already been fully processed by BrianASTRenderer