parse_expression_dimensions function

(Shortest import: from brian2.parsing.expressions import parse_expression_dimensions)

brian2.parsing.expressions.parse_expression_dimensions(expr, variables, orig_expr=None)[source]

Returns the unit value of an expression, and checks its validity

Parameters:

expr : str

The expression to check.

variables : dict

Dictionary of all variables used in the expr (including Constant objects for external variables)

Returns:

unit : Quantity

The output unit of the expression

Raises

SyntaxError

If the expression cannot be parsed, or if it uses a**b for b anything other than a constant number.

DimensionMismatchError

If any part of the expression is dimensionally inconsistent.