725b6fc0fc599663927c13dd661a79d63c66bda5,brian2/parsing/expressions.py,,parse_expression_dimensions,#Any#Any#,185
Before Change
elif op=="Div":
u = left/right
elif op=="Pow":
if have_same_dimensions(left, 1) and have_same_dimensions(right, 1):
return DIMENSIONLESS
n = _get_value_from_expression(expr.right, variables)
u = left**n
After Change
right_dim = parse_expression_dimensions(expr.right, variables)
if op in ["Add", "Sub", "Mod"]:
// dimensions should be the same
if left_dim is not right_dim:
op_symbol = {"Add": "+", "Sub": "-", "Mod": "%"}.get(op)
left_str = NodeRenderer().render_node(expr.left)
right_str = NodeRenderer().render_node(expr.right)
left_unit = repr(get_unit(left_dim))
right_unit = repr(get_unit(right_dim))
error_msg = ("Expression "{left} {op} {right}" uses "
"inconsistent units ("{left}" has unit "
"{left_unit}; "{right}" "
"has unit {right_unit})").format(left=left_str,
right=right_str,
op=op_symbol,
left_unit=left_unit,
right_unit=right_unit)
raise DimensionMismatchError(error_msg)
u = left_dim
elif op == "Mult":
u = left_dim*right_dim
elif op == "Div":
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: brian-team/brian2
Commit Name: 725b6fc0fc599663927c13dd661a79d63c66bda5
Time: 2017-01-16
Author: marcel.stimberg@inserm.fr
File Name: brian2/parsing/expressions.py
Class Name:
Method Name: parse_expression_dimensions
Project Name: brian-team/brian2
Commit Name: ac866bb4b13cde0499641c0ff8e368032f91892c
Time: 2014-04-02
Author: marcel.stimberg@ens.fr
File Name: brian2/core/variables.py
Class Name: Variable
Method Name: __init__
Project Name: brian-team/brian2
Commit Name: 4fc2fed2a6e3da28de4d77b4e3917952a0dfa562
Time: 2013-08-12
Author: marcel.stimberg@ens.fr
File Name: brian2/core/variables.py
Class Name: VariableView
Method Name: __repr__