Changeset 721

Show
Ignore:
Timestamp:
03/03/10 10:41:30 (2 years ago)
Author:
pierre
Message:

Speed up the DistanceDependentProbabilityConnector? in parallel in the new implementation, by computing only distances that will be used by the nodes. Spot also a bug, not fixed yet, with the positions in parallel. They are not correctly assigned by defaults

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/connectors.py

    r716 r721  
    134134                create = create[:projection.post.local_cells.size] 
    135135            targets = projection.post.local_cells[create].tolist() 
    136              
    137136            weights = self.get_weights(N, local)[create] 
    138137            weights = common.check_weight(weights, projection.synapse_type, is_conductance) 
     
    541540        p = {} 
    542541        for src in projection.pre.all(): 
    543             d = self.space.distances(src.position, projection.post.positions) 
     542            local = projection.post._mask_local.flatten() 
     543            d   = self.space.distances(src.position, projection.post.positions, post_mask=local) 
    544544            p[src] = eval(self.d_expression).flatten() 
    545545            if p[src].dtype == 'bool': 
  • trunk/src/space.py

    r712 r721  
    5353        self.offset = offset 
    5454         
    55     def distances(self, A, B): 
     55    def distances(self, A, B, post_mask=None): 
    5656        """ 
    5757        Calculate the distance matrix between two sets of coordinates, given 
     
    6666        d = numpy.zeros((A.shape[1], B.shape[1]), dtype=A.dtype) 
    6767        for axis in self.axes: 
    68             diff2 = A[axis,:,None] - B[axis,:] 
     68            diff2 = A[axis,:,None] - B[axis, post_mask] 
    6969            if self.periodic_boundaries is not None: 
    7070                boundaries = self.periodic_boundaries[axis] 
    7171                if boundaries is not None: 
    7272                    range = boundaries[1]-boundaries[0] 
    73                     ad2 = abs(diff2) 
     73                    ad2   = abs(diff2) 
    7474                    diff2 = numpy.minimum(ad2, range-ad2) 
    7575            diff2 **= 2 
    76             d += diff2 
    77         numpy.sqrt(d, d) 
     76            d[:,post_mask] += diff2 
     77        numpy.sqrt(d[:,post_mask], d[:,post_mask]) 
    7878        return d