# ArrayVariable class

(Shortest import: `from brian2.core.variables import ArrayVariable)`

class brian2.core.variables.ArrayVariable(name, owner, size, device, dimensions=Dimension(), dtype=None, constant=False, scalar=False, read_only=False, dynamic=False, unique=False)

  Bases: `Variable`

  An object providing information about a model variable stored in an array (for example, all state variables). Most of the time `Variables.add_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).

    dimensions : `Dimension`, optional

    > The physical dimensions 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

    > The size of the array

    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`.

    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

  `conditional_write` | Another variable, on which the write is conditioned (e.g. a variable denoting the absence of refractoriness).
  `device` | The `Device` responsible for memory access.
  `size` | The size of this variable.
  `unique` | Wether all values in this arrays are necessarily unique (only relevant for index variables).

  Methods

  `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 `0` for a scalar variable.
  `get_value`() | Return the value associated with the variable (without units).
  `item`() |
  `set_conditional_write`(var) |
  `set_value`(value) | Set the value associated with the variable.

  Details

  conditional_write

    Another variable, on which the write is conditioned (e.g. a variable denoting the absence of refractoriness)

  device

    The `Device` responsible for memory access.

  size

    The size of this variable.

  unique

    Wether all values in this arrays are necessarily unique (only relevant for index variables).

  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. For example, if a postsynaptic variable `x` is accessed in a synapse `S` as `S.x_post`, the synaptic indexing scheme can be used.

    Parameters:

      name : str

      > The name of the variable

      group : `Group`

      > The group providing the context for the indexing. Note that this `group` is not necessarily the same as `Variable.owner`: a variable owned by a `NeuronGroup` can be indexed in a different way if accessed via a `Synapses` object.

    Returns:

      variable : object

      > The variable in an indexable form (without units).

  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. For example, if a postsynaptic variable `x` is accessed in a synapse `S` as `S.x_post`, the synaptic indexing scheme can be used.

    Parameters:

      name : str

      > The name of the variable

      group : `Group`

      > The group providing the context for the indexing. Note that this `group` is not necessarily the same as `Variable.owner`: a variable owned by a `NeuronGroup` can be indexed in a different way if accessed via a `Synapses` object.

    Returns:

      variable : object

      > The variable in an indexable form (with units).

  get_len()

    Get the length of the value associated with the variable or `0` for a scalar variable.

  get_value()

    Return the value associated with the variable (without units). This is the way variables are accessed in generated code.

  item()
  set_conditional_write(var)
  set_value(value)

    Set the value associated with the variable.