DynamicArrayVariable class

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

class brian2.core.variables.DynamicArrayVariable(name, unit, owner, size, device, dtype=None, constant=False, constant_size=True, resize_along_first=False, scalar=False, read_only=False, unique=False)[source]

Bases: brian2.core.variables.ArrayVariable

An object providing information about a model variable stored in a dynamic array (used in Synapses). Most of the time Variables.add_dynamic_array should be used instead of instantiating this class directly.

Parameters:

name : ‘str’

The name of the variable. Note that this refers to the original name in the owning group. The same variable may be known under other names in other groups (e.g. the variable v of a NeuronGroup is known as v_post in a Synapse connecting to the group).

unit : Unit

The unit of the variable

owner : Nameable

The object that “owns” this variable, e.g. the NeuronGroup or Synapses object that declares the variable in its model equations.

size : int or tuple of int

The (initial) size of the variable.

device : Device

The device responsible for the memory access.

dtype : dtype, optional

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

constant : bool, optional

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

constant_size : bool, optional

Whether the size of the variable is constant during a run. Defaults to True.

scalar : bool, optional

Whether this array is a 1-element array that should be treated like a scalar (e.g. for a single delay value across synapses). Defaults to False.

read_only : bool, optional

Whether this is a read-only variable, i.e. a variable that is set internally and cannot be changed by the user. Defaults to False.

unique : bool, optional

Whether the values in this array are all unique. This information is only important for variables used as indices and does not have to reflect the actual contents of the array but only the possibility of non-uniqueness (e.g. synaptic indices are always unique but the corresponding pre- and post-synaptic indices are not). Defaults to False.

Attributes

constant_size Whether the size of the variable is constant during a run.
dimensions The number of dimensions
resize_along_first Whether this array will be only resized along the first dimension

Methods

resize(new_size) Resize the dynamic array.

Details

constant_size

Whether the size of the variable is constant during a run.

dimensions

The number of dimensions

resize_along_first

Whether this array will be only resized along the first dimension

resize(new_size)[source]

Resize the dynamic array. Calls self.device.resize to do the actual resizing.

Parameters:

new_size : int or tuple of int

The new size.