def set_types(self, syn_type, nodes=None, fraction=None): ''' Set the synaptic/connection types. .. warning :: The special "type" attribute cannot be modified when using graphs that inherit from the :class:`~nngt.Network` class. This is because for biological networks, neurons make only one kind of synapse, which is determined by the :class:`nngt.core.NeuralGroup` they belong to. Parameters ---------- syn_type : int or string Type of the connection among 'excitatory' (also `1`) or 'inhibitory' (also `-1`). nodes : int, float or list, optional (default: `None`) If `nodes` is an int, number of nodes of the required type that will be created in the graph (all connections from inhibitory nodes are inhibitory); if it is a float, ratio of `syn_type` nodes in the graph; if it is a list, ids of the `syn_type` nodes. fraction : float, optional (default: `None`) Fraction of the selected edges that will be set as `syn_type` (if `nodes` is not `None`, it is the fraction of the specified nodes' edges, otherwise it is the fraction of all edges in the graph). Returns ------- t_list : :class:`numpy.ndarray` List of the types in an order that matches the `edges` attribute of the graph. ''' inhib_nodes = nodes if syn_type == 'excitatory' or syn_type == 1: if issubclass(nodes.__class__, int): inhib_nodes = graph.node_nb() - nodes elif issubclass(nodes.__class__, float): inhib_nodes = 1./nodes elif hasattr(nodes, '__iter__'): inhib_nodes = list(range(graph.node_nb())) nodes.sort() for node in nodes[::-1]: del inhib_nodes[node] return Connections.types(self, inhib_nodes, fraction)