Changeset 1009

Show
Ignore:
Timestamp:
11/22/11 15:52:42 (6 months ago)
Author:
apdavison
Message:

Fixes to CSAConnector in 0.7 branch

Location:
branches/0.7
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/0.7/examples/VAbenchmarks2-csa.py

    r915 r1009  
    126126inh_cells = all_cells[n_exc:] 
    127127if benchmark == "COBA": 
    128     ext_stim = Population(20, SpikeSourcePoisson,{'rate' : rate, 'duration' : stim_dur},"expoisson") 
     128    ext_stim = Population(20, SpikeSourcePoisson, {'rate' : rate, 'duration' : stim_dur}, label="expoisson") 
    129129    rconn = 0.01 
    130130    ext_conn = FixedProbabilityConnector(rconn, weights=0.1) 
    131131 
    132132print "%s Initialising membrane potential to random values..." % node_id 
    133 rng = NumpyRNG(seed=rngseed, parallel_safe=parallel_safe, rank=node_id, num_processes=np) 
     133rng = NumpyRNG(seed=rngseed, parallel_safe=parallel_safe) 
    134134uniformDistr = RandomDistribution('uniform', [v_reset,v_thresh], rng=rng) 
    135135all_cells.initialize('v', uniformDistr) 
  • branches/0.7/src/connectors.py

    r957 r1009  
    895895            Connector.__init__(self, None, None, safe=safe, verbose=verbose) 
    896896            self.cset = cset 
    897             if cset.arity == 0: 
     897            if csa.arity(cset) == 0: 
    898898                #assert weights is not None and delays is not None, \ 
    899899                #       'must specify weights and delays in addition to a CSA mask' 
     
    905905                    self.delays = common.get_min_delay() 
    906906            else: 
    907                 assert cset.arity == 2, 'must specify mask or connection-set with arity 2' 
     907                assert csa.arity(cset) == 2, 'must specify mask or connection-set with arity 2' 
    908908                assert weights is None and delays is None, \ 
    909909                       "weights or delays specified both in connection-set and as CSAConnector argument" 
     
    923923    def connect(self, projection): 
    924924        """Connect-up a Projection.""" 
    925         i0 = projection.pre.first_id 
    926         size1 = projection.pre.last_id - i0 
    927         j0 = projection.post.first_id 
    928         targets = [j - j0 for j in projection.post] 
    929  
    930         # Cut out finite part and shift to global ids 
    931         c = csa.shift (i0, j0) * csa.cross ((0, size1), targets) * self.cset 
    932          
    933         if csa.arity (self.cset) == 2: 
     925        # Cut out finite part 
     926        c = csa.cross((0, projection.pre.size-1), (0, projection.post.size-1)) * self.cset 
     927         
     928        if csa.arity(self.cset) == 2: 
    934929            # Connection-set with arity 2 
    935930            for (i, j, weight, delay) in c: 
    936                 projection.connection_manager.connect (i, [j], weight, delay) 
     931                projection.connection_manager.connect (projection.pre[i], [projection.post[j]], weight, delay) 
    937932        elif CSAConnector.isConstant (self.weights) \ 
    938933             and CSAConnector.isConstant (self.delays): 
    939934            # Mask with constant weights and delays 
    940935            for (i, j) in c: 
    941                 projection.connection_manager.connect (i, [j], self.weights, self.delays) 
     936                projection.connection_manager.connect (projection.pre[i], [projection.post[j]], self.weights, self.delays) 
    942937        else: 
    943938            # Mask with weights and/or delays iterable 
     
    949944                delays = CSAConnector.constantIterator (delays) 
    950945            for (i, j), weight, delay in zip (c, weights, delays): 
    951                 projection.connection_manager.connect (i, [j], weight, delay) 
     946                projection.connection_manager.connect (projection.pre[i], [projection.post[j]], weight, delay)