Changeset 405

Show
Ignore:
Timestamp:
06/28/08 09:39:13 (5 months ago)
Author:
pierre
Message:

Confusion in the FixNumberPre? and FixNumberPost? connectors in nest2 as noted by pyNN users here. Others minors stuff not really interesting

Files:

Legend:

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

    r399 r405  
    215215    if not periodic_boundaries == None: 
    216216        d = numpy.minimum(abs(d),periodic_boundaries-abs(d)) 
    217         #d = numpy.array(map(min, ((x_i, y_i) for (x_i, y_i) in zip(abs(d), periodic_boundaries-abs(d))))) 
    218217    if mask is not None: 
    219218        d = d[mask] 
     
    246245            diff2 = diff2.flatten() 
    247246            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)))) 
    249247            diff2 = diff2.reshape(dims) 
    250248        diff2 **= 2 
  • trunk/src/nest1/connectors.py

    r404 r405  
    113113        for post in postsynaptic_neurons: 
    114114            distances = common.distances(projection.pre, post, self.mask, self.scale_factor, self.offset, periodic_boundaries) 
     115            # We evaluate the probabilities of connections for those distances 
    115116            func = eval("lambda d: %s" %self.d_expression) 
    116117            distances[:,0] = func(distances[:,0]) 
    117118            rarr = rng.uniform(0, 1, len(distances[:,0]),) 
     119            # We get the list of cells that will established a connection 
    118120            idx = numpy.where((distances[:,0] >= 1) | ((0 < distances[:,0]) & (distances[:,0] < 1) & (rarr < distances[:,0])))[0] 
    119121            source_list = presynaptic_neurons[idx].tolist() 
    120             if self.allow_self_connections: 
     122            # We remove the post cell if we don't allow self connections 
     123            if not self.allow_self_connections: 
    121124                try: 
    122125                    source_list.remove(post) 
    123126                except Exception: 
    124127                    pass 
    125             #for pre in presynaptic_neurons: 
    126                 #if self.allow_self_connections or pre != post:  
    127                     ## calculate the distance between the two cells : 
    128                     #p = distances[idx_pre,0] 
    129                     #if p >= 1 or (0 < p < 1 and rarr[j] < p): 
    130                         #source_list.append(pre) 
    131                 #j += 1 
    132                 #idx_pre += 1 
    133128            N = len(source_list) 
    134129            weights = self.getWeights(N) 
  • trunk/src/nest2/__init__.py

    r403 r405  
    144144            nest_filename = _merge_files(self._device, gather) 
    145145            data = recording.readArray(nest_filename, sepchar=None) 
    146             os.remove(nest_filename) 
     146            #os.remove(nest_filename) 
    147147            if data.size > 0: 
    148148                # the following returns indices, not IDs. I'm not sure this is what we want. 
     
    164164                user_filename += '.%d' % rank() 
    165165            if gather == False or rank() == 0: # if we gather, only do this on the master node 
    166                 recording.write_compatible_output(nest_filename, user_filename, Recorder.formats[self.variable], 
    167                                                   self.population, get_time_step()) 
     166                recording.write_compatible_output(nest_filename, user_filename, Recorder.formats[self.variable],self.population, get_time_step()) 
    168167        else: 
    169168            system_line = 'cat %s >> %s' % (nest_filename, user_filename) 
     
    767766        else: 
    768767            rng = rng or numpy.random 
    769             for neuron in rng.permutation(numpy.reshape(self.cell, (self.cell.size,)))[0:n_rec]: 
    770                 tmp_list.append(neuron) 
     768            tmp_list = rng.permutation(numpy.reshape(self.cell, (self.cell.size,)))[0:n_rec] 
    771769 
    772770        self.recorders[variable].record(tmp_list) 
  • trunk/src/nest2/connectors.py

    r404 r405  
    131131            rng = numpy.random 
    132132        for pre in presynaptic_neurons: 
     133            # We compute the distances from the post cell to all the others 
    133134            distances = common.distances(pre, projection.post, self.mask, 
    134135                                         self.scale_factor, self.offset, 
    135136                                         periodic_boundaries) 
     137            # We evaluate the probabilities of connections for those distances 
    136138            func = eval("lambda d: %s" %self.d_expression) 
    137139            distances[0] = func(distances[0]) 
     140            # We get the list of cells that will established a connection 
    138141            rarr = rng.uniform(0, 1, len(distances[0,:]),) 
    139142            idx = numpy.where((distances[0,:] >= 1) | ((0 < distances[0,:]) & (distances[0,:] < 1) & (rarr < distances[0,:])))[0] 
    140143            target_list = postsynaptic_neurons[idx].tolist() 
    141             if self.allow_self_connections: 
     144            # We remove the pre cell if we don't allow self connections 
     145            if not self.allow_self_connections: 
    142146                try: 
    143147                    target_list.remove(pre) 
    144148                except Exception: 
    145149                    pass 
    146             #for post in postsynaptic_neurons: 
    147             #    if self.allow_self_connections or pre != post:  
    148                     # calculate the distance between the two cells : 
    149             #        p = distances[0,idx_post] 
    150             #        if p >= 1 or (0 < p < 1 and rarr[j] < p): 
    151             #            target_list.append(post) 
    152             #    j += 1 
    153             #    idx_post += 1 
    154150            N = len(target_list) 
    155151            weights = self.getWeights(N) 
     
    163159 
    164160 
    165 class FixedNumberPreConnector(common.FixedNumberPreConnector): 
     161class FixedNumberPostConnector(common.FixedNumberPostConnector): 
    166162     
    167163    def connect(self, projection): 
     
    185181            weights = _convertWeight(weights, projection.synapse_type).tolist() 
    186182            delays = self.getDelays(N).tolist() 
    187  
     183            print target_list,[pre] 
    188184            nest.DivergentConnectWD([pre], target_list.tolist(), weights, delays) 
    189  
    190185            projection._sources += [pre]*N 
    191186            conn_dict = nest.GetConnections([pre], projection._plasticity_model)[0] 
     
    209204    return n 
    210205 
    211 class FixedNumberPostConnector(common.FixedNumberPostConnector): 
     206class FixedNumberPreConnector(common.FixedNumberPreConnector): 
    212207     
    213208    def connect(self, projection): 
  • trunk/src/recording.py

    r400 r405  
    6868    # Writing spiketimes, cell_id-min(cell_id)                     
    6969    # open file 
    70     if os.path.getsize(sim_filename) > 0: 
     70     
     71    try:  
     72        N = os.path.getsize(sim_filename) 
     73    except Exception: 
     74        N = 0 
     75     
     76    if N > 0: 
    7177        data = readArray(sim_filename, sepchar=None) 
    7278