VariableView class¶
(Shortest import: from brian2.core.variables import VariableView)
-
class
brian2.core.variables.
VariableView
(name, variable, group, dimensions=None)[source]¶ Bases:
object
A view on a variable that allows to treat it as an numpy array while allowing special indexing (e.g. with strings) in the context of a
Group
.Attributes
dtype
ndim
shape
unit
The Unit
of this variableMethods
get_item
(item[, level, namespace])Get the value of this variable. get_subexpression_with_index_array
(item, …)get_with_expression
(code, run_namespace)Gets a variable using a string expression. get_with_index_array
(item)set_item
(item, value[, level, namespace])Set this variable. set_with_expression
(item, code, run_namespace)Sets a variable using a string expression. set_with_expression_conditional
(cond, code, …)Sets a variable using a string expression and string condition. set_with_index_array
(item, value, check_units)Details
-
dtype
¶
-
ndim
¶
-
shape
¶
-
get_item
(item, level=0, namespace=None)[source]¶ Get the value of this variable. Called by
__getitem__
.
-
get_with_expression
(code, run_namespace)[source]¶ Gets a variable using a string expression. Is called by
VariableView.get_item
for statements such asprint(G.v['g_syn > 0'])
.
-
set_item
(item, value, level=0, namespace=None)[source]¶ Set this variable. This function is called by
__setitem__
but there is also a situation where it should be called directly: if the context for string-based expressions is higher up in the stack, this function allows to set thelevel
argument accordingly.
-
set_with_expression
(item, code, run_namespace, check_units=True)[source]¶ Sets a variable using a string expression. Is called by
VariableView.set_item
for statements such asS.var[:, :] = 'exp(-abs(i-j)/space_constant)*nS'
-
set_with_expression_conditional
(cond, code, run_namespace, check_units=True)[source]¶ Sets a variable using a string expression and string condition. Is called by
VariableView.set_item
for statements such asS.var['i!=j'] = 'exp(-abs(i-j)/space_constant)*nS'
-