Variable class¶
(Shortest import: from brian2.core.variables import Variable)
-
class
brian2.core.variables.Variable(name, dimensions=Dimension(), owner=None, dtype=None, scalar=False, constant=False, read_only=False, dynamic=False, array=False)[source]¶ Bases:
brian2.utils.caching.CacheKeyAn object providing information about model variables (including implicit variables such as
torxi). This class should never be instantiated outside of testing code, use one of its subclasses instead.Attributes
arrayWhether the variable is an array constantWhether the variable is constant during a run dimThe variable’s dimensions. dtypeThe dtype used for storing the variable. dtype_strString representation of the numpy dtype dynamicWhether the variable is dynamically sized (only for non-scalars) is_booleanis_integernameThe variable’s name. ownerThe Groupto which this variable belongs.read_onlyWhether the variable is read-only scalarWhether the variable is a scalar unitThe Unitof this variableMethods
get_addressable_value(name, group)Get the value (without units) of this variable in a form that can be indexed in the context of a group. get_addressable_value_with_unit(name, group)Get the value (with units) of this variable in a form that can be indexed in the context of a group. get_len()Get the length of the value associated with the variable or 0for a scalar variable.get_value()Return the value associated with the variable (without units). get_value_with_unit()Return the value associated with the variable (with units). set_value(value)Set the value associated with the variable. Details
-
array¶ Whether the variable is an array
-
constant¶ Whether the variable is constant during a run
-
dim¶ The variable’s dimensions.
-
dtype¶ The dtype used for storing the variable.
-
dtype_str¶ String representation of the numpy dtype
-
dynamic¶ Whether the variable is dynamically sized (only for non-scalars)
-
is_boolean¶
-
is_integer¶
-
name¶ The variable’s name.
-
read_only¶ Whether the variable is read-only
-
scalar¶ Whether the variable is a scalar
-
get_addressable_value(name, group)[source]¶ Get the value (without units) of this variable in a form that can be indexed in the context of a group. For example, if a postsynaptic variable
xis accessed in a synapseSasS.x_post, the synaptic indexing scheme can be used.
-
get_addressable_value_with_unit(name, group)[source]¶ Get the value (with units) of this variable in a form that can be indexed in the context of a group. For example, if a postsynaptic variable
xis accessed in a synapseSasS.x_post, the synaptic indexing scheme can be used.
-
get_len()[source]¶ Get the length of the value associated with the variable or
0for a scalar variable.
-