network module

class network.Network[source]

Bases: object

Cortix network.


int – Number of instances of this class.


Module super class constructor.


int – When using MPI the network will copy the data from all modules on the root process. This can generate an out of memory condition. This variable sets the maximum number of processes for which the data will be copied. Default is 1000.


Alternative name to module().

connect(module_port_a, module_port_b, info=None)[source]

Connect two modules using either their ports directly or inferred ports.

A connection always opens a channel for data communication in both ways. That is, both sends and receives are allowed.


The simplest form of usage is with arguments: (module_a, module_b). In this case, a port with the name of module_a must exist in module_b, and vice-versa (port names as str in lower case). In addition, the connect must not be called again with these same two modules, else the underlying connection will be overriden.

For more rigorous connection, the user is advised to fully specify the module and the port in each list argument.

  • module_port_a (list([Module,Port]) or list([Module,str]) or Module) – First module-port to connect.
  • module_port_b (list([Module,Port]) or list([Module,str]) or Module) – Second module-port to connect.
  • info (str) – Information on the directionality of the information flow. This is for graph visualization purposes only. The default value will use the order in the argument list to define the direction. Default: None. If set to bidiretional, will create a double headed arrow in the graph figure.
draw(graph_attr=None, node_attr=None, engine=None)[source]

Add a module.

n_networks = 0

Run the network simulation.

This function concurrently executes the function for each module in the network. Modules are run using either MPI or Multiprocessing, depending on the user configuration.


When using multiprocessing, data from the modules state are copied to the master process after the run() method of the modules is finished.