BrianObject class¶
(Shortest import: from brian2 import BrianObject)
-
class
brian2.core.base.BrianObject(**kwds)[source]¶ Bases:
brian2.core.names.NameableAll Brian objects derive from this class, defines magic tracking and update.
See the documentation for
Networkfor an explanation of which objects get updated in which order.Attributes
_clockThe clock used for simulating this object _creation_stackA string indicating where this object was created (traceback with any parts of Brian code removed) _networkUsed to remember the Networkin which this object has been included before, to raise an error if it is included in a newNetwork_scope_current_keyGlobal key value for ipython cell restrict magic _scope_keyThe scope key is used to determine which objects are collected by magic activeWhether or not the object should be run. add_to_magic_networkWhether or not the object should be added to a MagicNetwork.clockThe Clockdetermining when the object should be updated.code_objectsThe list of CodeObjectcontained within theBrianObject.contained_objectsThe list of objects contained within the BrianObject.invalidates_magic_networkWhether or not MagicNetworkis invalidated when a newBrianObjectof this type is addednameThe unique name for this object. namespaceThe group-specific namespace orderThe order in which objects with the same clock and whenshould be updatedupdatersThe list of Updaterthat define the runtime behaviour of this object.whenThe ID string determining when the object should be updated in Network.run.Methods
add_dependency(obj)Add an object to the list of dependencies. after_run()Optional method to do work after a run is finished. before_run(run_namespace)Optional method to prepare the object before a run. run()Details
-
_clock¶ The clock used for simulating this object
-
_creation_stack¶ A string indicating where this object was created (traceback with any parts of Brian code removed)
-
_network¶ Used to remember the
Networkin which this object has been included before, to raise an error if it is included in a newNetwork
-
_scope_current_key¶ Global key value for ipython cell restrict magic
-
_scope_key¶ The scope key is used to determine which objects are collected by magic
-
active¶ Whether or not the object should be run.
Inactive objects will not have their
updatemethod called inNetwork.run. Note that setting or unsetting theactiveattribute will set or unset it for allcontained_objects.
-
add_to_magic_network¶ Whether or not the object should be added to a
MagicNetwork. Note that all objects inBrianObject.contained_objectsare automatically added when the parent object is added, therefore e.g.NeuronGroupshould setadd_to_magic_networktoTrue, but it should not be set for all the dependent objects such asStateUpdater
-
clock¶ The
Clockdetermining when the object should be updated.Note that this cannot be changed after the object is created.
-
code_objects¶ The list of
CodeObjectcontained within theBrianObject.TODO: more details.
Note that this attribute cannot be set directly, you need to modify the underlying list, e.g.
obj.code_objects.extend([A, B]).
-
contained_objects¶ The list of objects contained within the
BrianObject.When a
BrianObjectis added to aNetwork, its contained objects will be added as well. This allows for compound objects which contain a mini-network structure.Note that this attribute cannot be set directly, you need to modify the underlying list, e.g.
obj.contained_objects.extend([A, B]).
-
invalidates_magic_network¶ Whether or not
MagicNetworkis invalidated when a newBrianObjectof this type is added
-
name¶ The unique name for this object.
Used when generating code. Should be an acceptable variable name, i.e. starting with a letter character and followed by alphanumeric characters and
_.
-
namespace¶ The group-specific namespace
-
order¶ The order in which objects with the same clock and
whenshould be updated
-
updaters¶ The list of
Updaterthat define the runtime behaviour of this object.TODO: more details.
Note that this attribute cannot be set directly, you need to modify the underlying list, e.g.
obj.updaters.extend([A, B]).
-
when¶ The ID string determining when the object should be updated in
Network.run.
-
add_dependency(obj)[source]¶ Add an object to the list of dependencies. Takes care of handling subgroups correctly (i.e., adds its parent object).
-
after_run()[source]¶ Optional method to do work after a run is finished.
Called by
Network.after_runafter the main simulation loop terminated.
-
before_run(run_namespace)[source]¶ Optional method to prepare the object before a run.
Called by
Network.after_runbefore the main simulation loop starts.
-