def __init__(self, cset, safe=True, callback=None): """ """ Connector.__init__(self, safe=safe, callback=callback) self.cset = cset arity = csa.arity(cset) assert arity in (0, 2), 'must specify mask or connection-set with arity 0 or 2'
def __init__( self, conn_list, safe=True, verbose=False, column_names=None, callback=None): """ :param conn_list: \ a list of tuples, one tuple for each connection. Each tuple\ should contain: `(pre_idx, post_idx, p1, p2, ..., pn)` where\ `pre_idx` is the index (i.e. order in the Population, not the ID)\ of the presynaptic neuron, `post_idx` is the index of the\ postsynaptic neuron, and `p1`, `p2`, etc. are the synaptic\ parameters (e.g., weight, delay, plasticity parameters). :param column_names: \ the names of the parameters p1, p2, etc. If not provided, it is\ assumed the parameters are weight, delay (for\ backwards compatibility). :param safe: \ if True, check that weights and delays have valid values. If\ False, this check is skipped. :param callback: \ if given, a callable that display a progress bar on the terminal. """ CommonFromListConnector.__init__( self, conn_list=conn_list, safe=safe, verbose=verbose, column_names=column_names) Connector.__init__(self, safe=safe, callback=callback)
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): Connector.__init__(self, weights, delays, space, safe) if isinstance(projection.rng, random.NativeRNG): raise Exception("Use of NativeRNG not implemented.") else: self.rng = projection.rng self.N = projection.pre.size idx = numpy.arange(self.N * rank(), self.N * (rank() + 1)) self.M = num_processes() * self.N self.local = numpy.ones(self.N, bool) self.local_long = numpy.zeros(self.M, bool) self.local_long[idx] = True self.weights_generator = WeightGenerator(weights, self.local_long, projection, safe) self.delays_generator = DelayGenerator(delays, self.local_long, safe) self.probas_generator = ProbaGenerator( random.RandomDistribution('uniform', (0, 1), rng=self.rng), self.local_long) self.distance_matrix = DistanceMatrix(projection.pre.positions, self.space, self.local) self.projection = projection self.candidates = projection.pre.all_cells self.allow_self_connections = allow_self_connections
def __init__(self, cset, safe=True, callback=None): """ """ Connector.__init__(self, safe=safe, callback=callback) self.cset = cset arity = csa.arity(cset) assert arity in (0, 2), 'must specify mask or connection-set with arity 0 or 2'
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): Connector.__init__(self, weights, delays, space, safe) if isinstance(projection.rng, random.NativeRNG): raise Exception("Use of NativeRNG not implemented.") else: self.rng = projection.rng if self.delays is None: self.delays = projection._simulator.state.min_delay self.N = projection.pre.size mpi_rank = projection._simulator.state.mpi_rank num_processes = projection._simulator.state.num_processes idx = numpy.arange(self.N*mpi_rank, self.N*(mpi_rank+1), dtype=numpy.int) self.M = num_processes*self.N self.local = numpy.ones(self.N, bool) self.local_long = numpy.zeros(self.M, bool) self.local_long[idx] = True self.weights_generator = WeightGenerator(weights, self.local_long, projection, safe) self.delays_generator = DelayGenerator(self.delays, self.local_long, kernel=projection._simulator.state, safe=safe) self.probas_generator = ProbaGenerator(random.RandomDistribution('uniform',(0,1), rng=self.rng), self.local_long) self.distance_matrix = DistanceMatrix(projection.pre.positions, self.space, self.local) self.projection = projection self.candidates = projection.pre.all_cells self.allow_self_connections = allow_self_connections
def __init__(self, conn_list, safe=True, verbose=False, column_names=None, callback=None): """ :param conn_list: \ a list of tuples, one tuple for each connection. Each tuple\ should contain: `(pre_idx, post_idx, p1, p2, ..., pn)` where\ `pre_idx` is the index (i.e. order in the Population, not the ID)\ of the presynaptic neuron, `post_idx` is the index of the\ postsynaptic neuron, and `p1`, `p2`, etc. are the synaptic\ parameters (e.g., weight, delay, plasticity parameters). :param column_names: \ the names of the parameters p1, p2, etc. If not provided, it is\ assumed the parameters are weight, delay (for\ backwards compatibility). :param safe: \ if True, check that weights and delays have valid values. If\ False, this check is skipped. :param callback: \ if given, a callable that display a progress bar on the terminal. """ # pylint: disable=too-many-arguments if conn_list is None or not len(conn_list): raise InvalidParameterType( "The connection list for the FromListConnector must contain" " at least a list of tuples, each of which should contain at " "least: (pre_idx, post_idx)") conn_list = numpy.array(conn_list) n_columns = 0 if conn_list.size: n_columns = conn_list.shape[1] weights = None delays = None self._extra_conn_data = None if column_names is None: # if no column names, but more not the expected if n_columns == 4: column_names = ('pre_idx', 'post_idx', 'weight', 'delay') conn_list, weights, delays, self._extra_conn_data = \ self._split_conn_list(conn_list, column_names) elif n_columns != 2: raise TypeError("Argument 'column_names' is required.") else: # separate conn list to pre, source, weight, delay and the # other things conn_list, weights, delays, self._extra_conn_data = \ self._split_conn_list(conn_list, column_names) # verify that the rest of the parameters are constant, as we don't # support synapse params changing per atom yet self._verify_extra_data_meets_constraints() # build common from list CommonFromListConnector.__init__(self, conn_list=conn_list, safe=safe, verbose=verbose) Connector.__init__(self, safe=safe, callback=callback) # set weights or / and delays if given if weights is not None or delays is not None: self.set_weights_and_delays(weights, delays)