AttributeVariable class

(Shortest import: from brian2.core.variables import AttributeVariable)

class brian2.core.variables.AttributeVariable(name, unit, obj, attribute, dtype=None, owner=None, constant=False, scalar=True)[source]

Bases: brian2.core.variables.Variable

An object providing information about a value saved as an attribute of an object. Instead of saving a reference to the value itself, we save the name of the attribute. This way, we get the correct value if the attribute is overwritten with a new value (e.g. in the case of clock.t_). Most of the time Variables.add_attribute_variable should be used instead of instantiating this class directly.

The object value has to be accessible by doing getattr(obj, attribute). Variables of this type are considered read-only.

Parameters:

name : str

The name of the variable

unit : Unit

The unit of the variable

obj : object

The object storing the attribute.

attribute : str

The name of the attribute storing the variable’s value. attribute has to be an attribute of obj.

dtype : dtype, optional

The dtype used for storing the variable. If none is given, defaults to core.default_float_dtype.

owner : Nameable, optional

The object that “owns” this variable, e.g. the NeuronGroup to which a dt value belongs (even if it is the attribute of a Clock object). Defaults to None.

constant : bool, optional

Whether the attribute’s value is constant during a run. Defaults to False.

scalar : bool, optional

Whether the variable is a scalar value (True) or vector-valued, e.g. defined for every neuron (False). Defaults to True.

Attributes

attribute The name of the attribute storing the variable’s value
obj The object storing the attribute

Methods

get_value()

Details

attribute

The name of the attribute storing the variable’s value

obj

The object storing the attribute

get_value()[source]