Changeset 716

Show
Ignore:
Timestamp:
02/19/10 16:58:37 (2 years ago)
Author:
apdavison
Message:

Using distance-dependent expressions for weights or delays in Connectors was broken. This needs to be back-ported to 0.6.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/doc/highlevelapi.txt

    r708 r716  
    405405In more abstract models, it is often useful to be able to avoid edge effects by specifying periodic boundary conditions, e.g.:: 
    406406 
    407     >>> connector = DistanceDependentProbabilityConnector("exp(-abs(d))", space=Space(periodic_boundaries=(500, 500, 0))) 
     407    >>> connector = DistanceDependentProbabilityConnector("exp(-abs(d))", space=Space(periodic_boundaries=((0,500), (0,500), None))) 
    408408     
    409409calculates distance on the surface of a torus of circumference 500 µm (wrap-around in the x- and y-dimensions but not z). 
  • trunk/src/connectors.py

    r713 r716  
    6161        self.w_index = 0 # should probably use a generator 
    6262        self.d_index = 0 # rather than storing these values 
    63         self.weights = weights 
    64         self.delays = delays 
     63        if isinstance(weights, basestring): 
     64            self.w_expr = weights 
     65            self.weights = numpy.empty((1,0)) 
     66        else: 
     67            self.weights = weights 
     68        if isinstance(delays, basestring): 
     69            self.d_expr = delays 
     70            self.delays = numpy.empty((1,0)) 
     71        else: 
     72            self.delays = delays 
    6573         
    6674        if delays is None: 
     
    540548                self.weights = numpy.concatenate((self.weights, eval(self.w_expr)), axis=1) 
    541549            if hasattr(self, 'd_expr'): 
     550                delays = eval(self.d_expr) 
    542551                self.delays = numpy.concatenate((self.delays, eval(self.d_expr)), axis=1) 
    543552        if hasattr(self.weights, 'shape'): self.weights = self.weights.flatten()