check_unit function¶
(Shortest import: from brian2.equations.unitcheck import check_unit)
-
brian2.equations.unitcheck.
check_unit
(expression, unit, variables)[source]¶ Compares the unit for an expression to an expected unit in a given namespace.
Parameters: expression : str
The expression to evaluate.
unit :
Unit
The expected unit for the
expression
.variables : dict
Dictionary of all variables (including external constants) used in the
expression
.Raises
KeyError
- In case on of the identifiers cannot be resolved.
DimensionMismatchError
- If an unit mismatch occurs during the evaluation.