Node module¶
Functions for node handling
- nest.lib.hl_api_nodes.Create(model, n=1, params=None, positions=None)¶
Create one or more nodes.
Generates n new network objects of the supplied model type. If n is not given, a single node is created. Note that if setting parameters of the nodes fail, the nodes will still have been created.
Note
If Create() is called with two arguments and the second argument (n) is a dictionary, this dictionary will be intepreted as params for backward compatibility.
During network construction, create all nodes representing model neurons first, then all nodes representing devices (generators, recorders, or detectors), or all devices first and then all neurons. Otherwise, network connection can be slow, especially in parallel simulations of networks with many devices.
- Parameters:
model (str) – Name of the model to create
n (int, optional) – Number of nodes to create
params (dict or list, optional) –
Parameters for the new nodes. Can be any of the following:
A dictionary with either single values or lists of size n. The single values will be applied to all nodes, while the lists will be distributed across the nodes. Both single values and lists can be given at the same time.
A list with n dictionaries, one dictionary for each node.
Values may be
Parameterobjects. If omitted, the model’s defaults are used.positions (
gridorfreeobject, optional) – Object describing spatial positions of the nodes. If omitted, the nodes have no spatial attachment.
- Returns:
Object representing the IDs of created nodes, see
NodeCollectionfor more.- Return type:
- Raises:
NESTError – If setting node parameters fail. However, the nodes will still have been created.
TypeError – If the positions object is of wrong type.
- nest.lib.hl_api_nodes.GetLocalNodeCollection(nc)¶
Get local nodes of a NodeCollection as a new NodeCollection.
This function returns the local nodes of a NodeCollection. If there are no local elements, an empty NodeCollection is returned.
Note
You should not use this function except in very special circumstances, e.g., in when writing tests. The main reason to avoid GetLocalNodeCollection() is that it is very difficult to get code correct that does different things on different MPI ranks. Remember that a NEST simulation should always return the same results if run with the same number of virtual processes, independent of how these VPs are distrbuted across MPI ranks.
Quite likely, you can do what you want using NEST’s parallel features, e.g., initializing neurons or synapses. If you see a need for a feature that needs to do rank-specific things, please consider to add it to NEST!
Since this function should not be used, it’s implementation is not efficient.
- Parameters:
nc (NodeCollection) – NodeCollection for which to get local nodes
- Returns:
Object representing the local nodes of the given NodeCollection
- Return type:
- nest.lib.hl_api_nodes.GetNodes(properties={}, local_only=False)¶
Return all nodes with the given properties as NodeCollection.
- Parameters:
properties (dict, optional) – Only node IDs of nodes matching the properties given in the dictionary exactly will be returned. Matching properties with float values (e.g. the membrane potential) may fail due to tiny numerical discrepancies and should be avoided. Note that when a params dict is present, thread parallelization is not possible, the function will be run thread serial.
local_only (bool, optional) – If True, only node IDs of nodes simulated on the local MPI process will be returned. By default, node IDs of nodes in the entire simulation will be returned. This requires MPI communication and may slow down the script.
- Returns:
NodeCollection of nodes
- Return type:
- nest.lib.hl_api_nodes.PrintNodes()¶
Print the node ID ranges and model names of all the nodes in the network.