Device class¶
(Shortest import: from brian2.devices import Device)
-
class
brian2.devices.device.
Device
[source]¶ Bases:
object
Base Device object.
Attributes
network_schedule
The network schedule that this device supports. Methods
activate
([build_on_run])Called when this device is set as the current device. add_array
(var)Add an array to this device. build
(**kwds)For standalone projects, called when the project is ready to be built. code_object
(owner, name, abstract_code, …)code_object_class
([codeobj_class, fallback_pref])Return CodeObject
class according to input/default settingsdelete
([data, code, directory, force])Delete code and/or data generated/stored by the 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_len
(array)Return the length of the array. get_random_state
()Return a (pickable) representation of the current random number generator state. init_with_arange
(var, start, dtype)Initialize an array with an integer range. init_with_zeros
(var, dtype)Initialize an array with zeros. insert_code
(slot, code)Insert code directly into a given slot in the device. insert_device_code
(slot, code)reinit
()Reinitialize the device. 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
).spike_queue
(source_start, source_end)Create and return a new SpikeQueue
for thisDevice
.Details
-
network_schedule
¶ The network schedule that this device supports. If the device only supports a specific, fixed schedule, it has to set this attribute to the respective schedule (see
Network.schedule
for details). If it supports arbitrary schedules, it should be set toNone
(the default).
-
activate
(build_on_run=True, **kwargs)[source]¶ Called when this device is set as the current device.
-
build
(**kwds)[source]¶ For standalone projects, called when the project is ready to be built. Does nothing for runtime mode.
-
code_object
(owner, name, abstract_code, variables, template_name, variable_indices, codeobj_class=None, template_kwds=None, override_conditional_write=None, compiler_kwds=None)[source]¶
-
code_object_class
(codeobj_class=None, fallback_pref='codegen.target')[source]¶ Return
CodeObject
class according to input/default settings
-
delete
(data=True, code=True, directory=True, force=False)[source]¶ Delete code and/or data generated/stored by the device.
-
get_random_state
()[source]¶ 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.
-
insert_code
(slot, code)[source]¶ Insert code directly into a given slot in the device. By default does nothing.
-
reinit
()[source]¶ Reinitialize the device. For standalone devices, clears all the internal state of the device.
-
set_random_state
(state)[source]¶ Reset the random number generator state to a previously stored state (see
Device.get_random_state
).
-