Changeset 398

Show
Ignore:
Timestamp:
06/26/08 14:05:31 (5 months ago)
Author:
pierre
Message:

I don't have commited the good files.... Sorry.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/common.py

    r397 r398  
    245245            dims  = diff2.shape 
    246246            diff2 = diff2.flatten() 
    247             #diff2 = numpy.minimum(diff2, periodic_boundaries[i]-diff2) 
    248             diff2 = numpy.array(map(min, ((x_i, y_i) for (x_i, y_i) in zip(diff2, periodic_boundaries[i]-diff2)))) 
     247            diff2 = numpy.minimum(diff2, periodic_boundaries[i]-diff2) 
     248            #diff2 = numpy.array(map(min, ((x_i, y_i) for (x_i, y_i) in zip(diff2, periodic_boundaries[i]-diff2)))) 
    249249            diff2 = diff2.reshape(dims) 
    250250        diff2 **= 2 
     
    14111411            raise 
    14121412        self.d_expression = d_expression 
     1413        # We will use the numpy functions, so we need to parse the function 
     1414        # given by the user to look for some key function and add numpy 
     1415        # in front of them (or add from numpy import *) 
     1416        func = ['exp','log','sin','cos','cosh','sinh','tan','tanh'] 
     1417        for item in func: 
     1418            self.d_expression = self.d_expression.replace(item,"numpy.%s" %item) 
    14131419        self.allow_self_connections = allow_self_connections 
    14141420        self.mask = DistanceDependentProbabilityConnector.AXES[axes] 
  • trunk/src/nest2/connectors.py

    r397 r398  
    136136                                         self.scale_factor, self.offset, 
    137137                                         periodic_boundaries) 
     138            func = eval("lambda d: %s" %self.d_expression) 
     139            distances[0] = func(distances[0]) 
    138140            for post in postsynaptic_neurons: 
    139                 func = eval("lambda d: %s" %self.d_expression) 
    140                 distances[0] = func(distances[0]) 
    141141                #probabilities = map(func,distances[0]) 
    142                  
    143142                if self.allow_self_connections or pre != post:  
    144143                    # calculate the distance between the two cells :