# RuntimeDevice class

(Shortest import: `from brian2.devices import RuntimeDevice)`

class brian2.devices.device.RuntimeDevice

  Bases: `Device`

  The default device used in Brian, state variables are stored as numpy arrays in memory.

  Attributes

  `arrays` | Mapping from `Variable` objects to numpy arrays (or `DynamicArray` objects).

  Methods

  `add_array`(var) | Add an array to this device.
  `fill_with_array`(var, arr) | Fill an array with the values given in another array.
  `get_array_name`(var[, access_data]) | Return a globally unique name for `var`.
  `get_random_state`() | Return a (pickable) representation of the current random number generator state.
  `get_value`(var[, access_data]) |
  `init_with_arange`(var, start, dtype) | Initialize an array with an integer range.
  `init_with_zeros`(var, dtype) | Initialize an array with zeros.
  `resize`(var, new_size) | Resize a `DynamicArrayVariable`.
  `resize_along_first`(var, new_size) |
  `seed`([seed]) | Set the seed for the random number generator.
  `set_random_state`(state) | Reset the random number generator state to a previously stored state (see `Device.get_random_state`).
  `set_value`(var, value) |
  `spike_queue`(source_start, source_end) | Create and return a new `SpikeQueue` for this `Device`.

  Details

  arrays

    Mapping from `Variable` objects to numpy arrays (or `DynamicArray` objects). Arrays in this dictionary will disappear as soon as the last reference to the `Variable` object used as a key is gone

  add_array(var)

    Add an array to this device.

    Parameters:

      var : `ArrayVariable`

      > The array to add.

  fill_with_array(var, arr)

    Fill an array with the values given in another array.

    Parameters:

      var : `ArrayVariable`

      > The array to fill.

      arr : `ndarray`

      > The array values that should be copied to `var`.

  get_array_name(var, access_data=True)

    Return a globally unique name for `var`.

    Parameters:

      access_data : bool, optional

      > For `DynamicArrayVariable` objects, specifying `True` here means the name for the underlying data is returned. If specifying `False`, the name of object itself is returned (e.g. to allow resizing).

    Returns:

      name : str

      > The name for `var`.

  get_random_state()

    Return a (pickable) representation of the current random number generator state. Providing the returned object (e.g. a dict) to `Device.set_random_state` should restore the random number generator state.

    Returns:

      state :

      > The state of the random number generator in a representation that can be passed as an argument to `Device.set_random_state`.

  get_value(var, access_data=True)
  init_with_arange(var, start, dtype)

    Initialize an array with an integer range.

    Parameters:

      var : `ArrayVariable`

      > The array to fill with the integer range.

      start : int

      > The start value for the integer range

      dtype : `dtype`

      > The data type to use for the array.

  init_with_zeros(var, dtype)

    Initialize an array with zeros.

    Parameters:

      var : `ArrayVariable`

      > The array to initialize with zeros.

      dtype : `dtype`

      > The data type to use for the array.

  resize(var, new_size)

    Resize a `DynamicArrayVariable`.

    Parameters:

      var : `DynamicArrayVariable`

      > The variable that should be resized.

      new_size : int

      > The new size of the variable

  resize_along_first(var, new_size)
  seed(seed=None)

    Set the seed for the random number generator.

    Parameters:

      seed : int, optional

      > The seed value for the random number generator, or `None` (the default) to set a random seed.

  set_random_state(state)

    Reset the random number generator state to a previously stored state (see `Device.get_random_state`).

    Parameters:

      state :

      > A random number generator state as provided by `Device.get_random_state`.

  set_value(var, value)
  spike_queue(source_start, source_end)

    Create and return a new `SpikeQueue` for this `Device`.

    Parameters:

      source_start : int

      > The start index of the source group (necessary for subgroups)

      source_end : int

      > The end index of the source group (necessary for subgroups)

## Tutorials and examples using this

- Example frompapers/Kremer_et_al_2011_barrel_cortex