# cancel_identical_terms function¶

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

brian2.codegen.optimisation.cancel_identical_terms(primary, inverted)[source]

Cancel terms in a collection, e.g. a+b-a should be cancelled to b

Simply renders the nodes into expressions and removes whenever there is a common expression in primary and inverted.

Parameters

primary : list of AST nodes

These are the nodes that are positive with respect to the operator, e.g. in x*y/z it would be [x, y].

inverted : list of AST nodes

These are the nodes that are inverted with respect to the operator, e.g. in x*y/z it would be [z].

Returns

primary : list of AST nodes

Primary nodes after cancellation

inverted : list of AST nodes

Inverted nodes after cancellation