Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
 def connect(self, projection):
     """Connect-up a Projection."""
     if self.distributed:
         self.filename += ".%d" % common.rank()
     # open the file...
     f = open(self.filename, 'r', 10000)
     lines = f.readlines()
     f.close()
     # gather all the data in a list of tuples (one per line)
     input_tuples = []
     for line in lines:
         single_line = line.rstrip()
         src, tgt, w, d = single_line.split("\t", 4)
         src = "[%s" % src.split("[",1)[1]
         tgt = "[%s" % tgt.split("[",1)[1]
         input_tuples.append((eval(src), eval(tgt), float(w), float(d)))
     self.conn_list = input_tuples
     FromListConnector.connect(self, projection)
Ejemplo n.º 3
0
 def connect(self, projection):
     """Connect-up a Projection."""
     if self.distributed:
         self.filename += ".%d" % common.rank()
     # open the file...
     f = open(self.filename, 'r', 10000)
     lines = f.readlines()
     f.close()
     # gather all the data in a list of tuples (one per line)
     input_tuples = []
     for line in lines:
         single_line = line.rstrip()
         src, tgt, w, d = single_line.split("\t", 4)
         src = "[%s" % src.split("[", 1)[1]
         tgt = "[%s" % tgt.split("[", 1)[1]
         input_tuples.append((eval(src), eval(tgt), float(w), float(d)))
     self.conn_list = input_tuples
     FromListConnector.connect(self, projection)
Ejemplo n.º 4
0
 def connect(self, projection):
     """Connect-up a Projection."""
     if self.distributed:
         self.file.rename("%s.%d" % (self.file.name, common.rank()))
     self.conn_list = self.file.read()
     FromListConnector.connect(self, projection)
Ejemplo n.º 5
0
 def progression(self, count):
     self.prog.update_amount(count)
     if self.verbose and common.rank() == 0:
         print self.prog, "\r",
         sys.stdout.flush()
Ejemplo n.º 6
0
 def progression(self, count):
     self.prog.update_amount(count)
     if self.verbose and common.rank() == 0:           
         print self.prog, "\r",
         sys.stdout.flush()