check_units_statements function¶
(Shortest import: from brian2.equations.unitcheck import check_units_statements)
-
brian2.equations.unitcheck.
check_units_statements
(code, variables)[source]¶ Check the units for a series of statements. Setting a model variable has to use the correct unit. For newly introduced temporary variables, the unit is determined and used to check the following statements to ensure consistency.
Parameters: code : str
The statements as a (multi-line) string
variables : dict of
Variable
objectsThe information about all variables used in
code
(includingConstant
objects for external variables)Raises
KeyError
- In case on of the identifiers cannot be resolved.
DimensionMismatchError
- If an unit mismatch occurs during the evaluation.