Nameable class
(Shortest import: from brian2 import Nameable)
- class brian2.core.names.Nameable(*args, **kw)[source]
Bases:
Trackable
Base class to find a unique name for an object
If you specify a name explicitly, and it has already been taken, a
ValueError
is raised. You can also specify a name with a wildcard asterisk in the end, i.e. in the form'name*'
. It will then tryname
first but if this is already specified, it will tryname_1
,name__2`
, etc. This is the default mechanism used by most core objects in Brian, e.g.NeuronGroup
uses a default name of'neurongroup*'
.Attributes
A unique id for this object.
The unique name for this object.
Methods
Assign a new id to this object.
Details
- id
A unique id for this object.
In contrast to names, which may be reused, the id stays unique. This is used in the dependency checking to not have to deal with the chore of comparing weak references, weak proxies and strong references.
- 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
_
.
- assign_id()[source]
Assign a new id to this object. Under most circumstances, this method should only be called once at the creation of the object to generate a unique id. In the case of the
MagicNetwork
, however, the id should change when a new, independent set of objects is simulated.