You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just ran into the following issue. When I define a variable in the namespace of an equation and the variable is also an internal variable, I get a warning that the internal variable is used. E.g.
WARNING "xi_custom" is an internal variable of group "neurongroup", but also exists in the run namespace with the value 1. The internal variable will be used. [brian2.groups.group.Group.resolve.resolution_conflict]
But if that namespace variable is a function instead, the dimensions check raises an error before the resolution conflict warning is given. E.g.:
does not give the helpful resolution conflict warning but instead raises the following error:
ERROR Brian 2 encountered an unexpected error. If you think this is bug in Brian 2, please report this issue either to the mailing list at <http://groups.google.com/group/brian-development/>, or to the issue tracker at <https://github.com/brian-team/brian2/issues>. Please include this file with debug information in your report: /tmp/brian_debug_6m7aulf4.log Additionally, you can also include a copy of the script that was run, available at: /tmp/brian_script_ju25mfpx.py Thanks! [brian2]
Traceback (most recent call last):
File "/path/to/brian2/brian2/core/network.py", line 897, in before_run
obj.before_run(run_namespace)
File "/path/to/brian2/brian2/groups/neurongroup.py", line 884, in before_run
self.equations.check_units(self, run_namespace=run_namespace)
File "/path/to/brian2/brian2/equations/equations.py", line 956, in check_units
check_dimensions(str(eq.expr), self.dimensions[var] / second.dim,
File "/path/to/brian2/brian2/equations/unitcheck.py", line 41, in check_dimensions
expr_dims = parse_expression_dimensions(expression, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 323, in parse_expression_dimensions
left_dim = parse_expression_dimensions(expr.left, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 324, in parse_expression_dimensions
right_dim = parse_expression_dimensions(expr.right, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 324, in parse_expression_dimensions
right_dim = parse_expression_dimensions(expr.right, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 279, in parse_expression_dimensions
raise ValueError(('Function %s does not specify how it '
ValueError: Function xi_custom does not specify how it deals with units.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/bla.py", line 15, in <module>
run(num_time_steps * defaultclock.dt)
File "/path/to/brian2/brian2/units/fundamentalunits.py", line 2385, in new_f
result = f(*args, **kwds)
File "/path/to/brian2/brian2/core/magic.py", line 373, in run
return magic_network.run(duration, report=report, report_period=report_period,
File "/path/to/brian2/brian2/core/magic.py", line 231, in run
Network.run(self, duration, report=report, report_period=report_period,
File "/path/to/brian2/brian2/core/base.py", line 276, in device_override_decorated_function
return func(*args, **kwds)
File "/path/to/brian2/brian2/units/fundamentalunits.py", line 2385, in new_f
result = f(*args, **kwds)
File "/path/to/brian2/brian2/core/network.py", line 1008, in run
self.before_run(namespace)
File "/path/to/brian2/brian2/core/base.py", line 276, in device_override_decorated_function
return func(*args, **kwds)
File "/path/to/brian2/brian2/core/network.py", line 899, in before_run
raise brian_object_exception("An error occurred when preparing an object.", obj, ex)
brian2.core.base.BrianObjectException: Original error and traceback:
Traceback (most recent call last):
File "/path/to/brian2/brian2/core/network.py", line 897, in before_run
obj.before_run(run_namespace)
File "/path/to/brian2/brian2/groups/neurongroup.py", line 884, in before_run
self.equations.check_units(self, run_namespace=run_namespace)
File "/path/to/brian2/brian2/equations/equations.py", line 956, in check_units
check_dimensions(str(eq.expr), self.dimensions[var] / second.dim,
File "/path/to/brian2/brian2/equations/unitcheck.py", line 41, in check_dimensions
expr_dims = parse_expression_dimensions(expression, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 323, in parse_expression_dimensions
left_dim = parse_expression_dimensions(expr.left, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 324, in parse_expression_dimensions
right_dim = parse_expression_dimensions(expr.right, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 324, in parse_expression_dimensions
right_dim = parse_expression_dimensions(expr.right, variables)
File "/path/to/brian2/brian2/parsing/expressions.py", line 279, in parse_expression_dimensions
raise ValueError(('Function %s does not specify how it '
ValueError: Function xi_custom does not specify how it deals with units.
Error encountered with object named "neurongroup".
Object was created here (most recent call only, full details in debug log):
File "/tmp/bla.py", line 13, in <module>
group = NeuronGroup(num_neurons, eqs)
An error occurred when preparing an object. ValueError: Function xi_custom does not specify how it deals with units.
(See above for original error message and traceback.)
Two issues here:
Is there a way to have the resolution conflict run before the unit expression raises an error? It is rather tricky to figure out why things are failing in the second example, because the function defined in namespace does correctly define how it deals with functions, but brian uses the internal xi_custom variable and fails to warn the user about that.
I couldn't really find anything about xi_<custom_name> variables in the user documentation. I came across is only by searching the source code. Could it be that it isn't documented that one can use xi_<custom_name> for noise variables? Or did I just not find it?
The text was updated successfully, but these errors were encountered:
Hi there,
I just ran into the following issue. When I define a variable in the namespace of an equation and the variable is also an internal variable, I get a warning that the internal variable is used. E.g.
Gives
But if that namespace variable is a function instead, the dimensions check raises an error before the resolution conflict warning is given. E.g.:
does not give the helpful resolution conflict warning but instead raises the following error:
Two issues here:
xi_custom
variable and fails to warn the user about that.xi_<custom_name>
variables in the user documentation. I came across is only by searching the source code. Could it be that it isn't documented that one can usexi_<custom_name>
for noise variables? Or did I just not find it?The text was updated successfully, but these errors were encountered: