Changeset 399

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

Update also the nest1 DistantDependantProbabilityConnector? to be coherent. Intensive use of Numpy.

Files:

Legend:

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

    r398 r399  
    14141414        # given by the user to look for some key function and add numpy 
    14151415        # 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) 
     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) 
    14191419        self.allow_self_connections = allow_self_connections 
    14201420        self.mask = DistanceDependentProbabilityConnector.AXES[axes] 
  • trunk/src/nest1/__init__.py

    r390 r399  
    823823        """ 
    824824        print "\n------- Population description -------" 
    825         print "Population called %s is made of %d cells" %(self.label, len(self.cell)) 
     825        print "Population called %s is made of %d cells" %(self.label, len(self.cell.flatten())) 
    826826        print "-> Cells are aranged on a %dD grid of size %s" %(len(self.dim), self.dim) 
    827827        print "-> Celltype is %s" %self.celltype 
    828828        print "-> Cell Parameters used for cell[0] (during initialization and now) are: "  
    829829        for key, value in self.cellparams.items(): 
    830           print "\t|", key, "\t: ", "init->", value, "\t now->", pynest.getDict([self.cell[0]])[0][key] 
     830          print "\t|", key, "\t: ", "init->", value, "\t now->", pynest.getDict([self.cell.flatten()[0]])[0][key] 
    831831        print "--- End of Population description ----" 
    832832         
  • trunk/src/nest1/connectors.py

    r392 r399  
    88from pyNN.random import RandomDistribution, NativeRNG 
    99from math import * 
     10from numpy import arccos, arcsin, arctan, arctan2, ceil, cos, cosh, e, exp, \ 
     11                  fabs, floor, fmod, hypot, ldexp, log, log10, modf, pi, power, \ 
     12                  sin, sinh, sqrt, tan, tanh 
    1013 
    1114common.get_min_delay = get_min_delay 
     
    9497        if periodic_boundaries is True: 
    9598            dimensions = projection.post.dim 
    96             periodic_boundaries = numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions)))) 
     99            periodic_boundaries = tuple(numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions))))) 
    97100        if periodic_boundaries: 
    98             print "Periodic boundaries set to size ", periodic_boundaries 
     101            print "Periodic boundaries activated and set to size ", periodic_boundaries 
    99102        postsynaptic_neurons = numpy.reshape(projection.post.cell,(projection.post.cell.size,)) 
    100103        presynaptic_neurons  = numpy.reshape(projection.pre.cell,(projection.pre.cell.size,)) 
     
    113116            idx_pre  = 0 
    114117            distances = common.distances(projection.pre, post, self.mask, self.scale_factor, self.offset, periodic_boundaries) 
     118            func = eval("lambda d: %s" %self.d_expression) 
     119            distances[:,0] = func(distances[:,0]) 
     120             
    115121            for pre in presynaptic_neurons: 
    116122                if self.allow_self_connections or pre != post:  
    117123                    # calculate the distance between the two cells : 
    118                     d = distances[idx_pre][0] 
    119                     p = eval(self.d_expression) 
     124                    p = distances[idx_pre,0] 
    120125                    if p >= 1 or (0 < p < 1 and rarr[j] < p): 
    121126                        source_list.append(pre) 
    122                         #projection._targets.append(post) 
    123                         #projection._targetPorts.append(pynest.connectWD(pre_addr, post_addr, weight, delay))  
    124127                j += 1 
    125128                idx_pre += 1 
  • trunk/src/nest2/connectors.py

    r398 r399  
    1212from pyNN.random import RandomDistribution, NativeRNG 
    1313from math import * 
     14from numpy import arccos, arcsin, arctan, arctan2, ceil, cos, cosh, e, exp, \ 
     15                  fabs, floor, fmod, hypot, ldexp, log, log10, modf, pi, power, \ 
     16                  sin, sinh, sqrt, tan, tanh 
    1417 
    1518def _convertWeight(w, synapse_type): 
     
    113116        if periodic_boundaries is True: 
    114117            dimensions = projection.post.dim 
    115             periodic_boundaries = numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions)))) 
     118            periodic_boundaries = tuple(numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions))))) 
    116119        if periodic_boundaries: 
    117             print "Periodic boundaries set to size ", periodic_boundaries 
     120            print "Periodic boundaries activated and set to size ", periodic_boundaries 
    118121        postsynaptic_neurons = projection.post.cell.flatten() # array 
    119122        presynaptic_neurons  = projection.pre.cell.flat # iterator  
     
    139142            distances[0] = func(distances[0]) 
    140143            for post in postsynaptic_neurons: 
    141                 #probabilities = map(func,distances[0]) 
    142144                if self.allow_self_connections or pre != post:  
    143145                    # calculate the distance between the two cells : 
    144                     #d = distances[0][idx_post] 
    145                     #p = eval(self.d_expression) 
    146                     p = distances[0][idx_post] 
     146                    p = distances[0,idx_post] 
    147147                    if p >= 1 or (0 < p < 1 and rarr[j] < p): 
    148148                        target_list.append(post) 
    149                         #projection._targets.append(post) 
    150                         #projection._target_ports.append(nest.connect(pre_addr,post_addr)) 
    151                         #nest.ConnectWD([pre],[post], [weight], [delay]) 
    152149                j += 1 
    153150                idx_post += 1 
  • trunk/src/neuron2/connectors.py

    r392 r399  
    124124        if periodic_boundaries is True: 
    125125            dimensions = projection.post.dim 
    126             periodic_boundaries = numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions)))) 
     126            periodic_boundaries = tuple(numpy.concatenate((dimensions, numpy.zeros(3-len(dimensions))))) 
    127127        if periodic_boundaries: 
    128             print "Periodic boundaries set to size ", periodic_boundaries 
    129         j = 0 
     128            print "Periodic boundaries activated and set to size ", periodic_boundaries 
    130129        # this is not going to work for parallel sims 
    131130        # either build up d gradually by iterating over local target cells,