Changeset 287

Show
Ignore:
Timestamp:
11/05/08 14:14:42 (2 months ago)
Author:
pierre
Message:

Minors functions added. Tests are also slightly modified. Now, if you have updated pyNN to the trunk version, and if you have nest2 installed, you should see that tests on the headers are passed. Two populations are created and recorded, and the numbers or cells saved/loaded is correct

Files:

Legend:

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

    r281 r287  
    21652165    def min(self): 
    21662166        return self.signal.min() 
     2167     
     2168    def mean(self): 
     2169        return numpy.mean(self.signal) 
    21672170 
    21682171    def copy(self): 
     
    23212324 
    23222325        Inputs: 
    2323             events  - Can be a SpikeTrain object (and events will be the spikes) or just a list  
     2326            events  - Can be a SpikeTrain object (and events will be the spikes) or just a list  
    23242327                      of times 
    23252328            t_min   - Time (>0) to cut the signal before an event, in ms (default 100) 
    23262329            t_max   - Time (>0) to cut the signal after an event, in ms  (default 100) 
    23272330         
     2331        Examples: 
     2332            >> res = aslist.slice_by_events([100,200,300], t_min=0, t_max =100) 
     2333            >> print len(res) 
     2334                3 
    23282335        """ 
    23292336        if isinstance(events, SpikeTrain): 
     
    25452552        new_AnalogSignalList.__calc_startstop() 
    25462553        return new_AnalogSignalList 
     2554 
     2555    def select_ids(self, criteria=None): 
     2556        """ 
     2557        Return the list of all the cells in the AnalogSignalList that will match the criteria 
     2558        expressed with the following syntax.  
     2559         
     2560        Inputs :  
     2561            criteria - a string that can be evaluated on a AnalogSignal object, where the  
     2562                       AnalogSignal should be named ``cell''. 
     2563         
     2564        Exemples: 
     2565            >> aslist.select_ids("mean(cell.signal) > 20") 
     2566            >> aslist.select_ids("cell.std() < 0.2") 
     2567        """ 
     2568        selected_ids = [] 
     2569        for id in self.id_list(): 
     2570            cell = self.analog_signals[id] 
     2571            if eval(criteria): 
     2572                selected_ids.append(id) 
     2573        return selected_ids 
    25472574 
    25482575    def convert(self, format="[values, ids]"): 
  • trunk/test/test_signals.py

    r279 r287  
    508508        assert len(self.analog.std()) == len(self.analog[0]) 
    509509 
     510    def testSelectIds(self): 
     511        assert type(self.analog.select_ids("cell.mean() > 0")) == list 
    510512 
    511513 
     
    604606        p1.print_v("Simulation/p1.v") 
    605607        p1.print_c("Simulation/p1.c") 
    606         p2.printSpikes(rec.StandardPickleFile("Simulation/p2.spikes")
    607         p2.print_v(rec.StandardPickleFile("Simulation/p2.v")
    608         p2.print_c(rec.StandardPickleFile("Simulation/p2.c")
     608        p2.printSpikes("Simulation/p2.spikes"
     609        p2.print_v("Simulation/p2.v"
     610        p2.print_c("Simulation/p2.c"
    609611     
    610612    def testLoadFirstPopulationData(self): 
    611         spikes = signals.load(io.StandardTextFile("Simulation/p1.spikes"),'s') 
    612         vm     = signals.load(io.StandardTextFile("Simulation/p1.v"),'v') 
    613         ge, gi = signals.load(io.StandardTextFile("Simulation/p1.c"),'g') 
     613        spikes = signals.load("Simulation/p1.spikes",'s') 
     614        vm     = signals.load("Simulation/p1.v",'v') 
     615        ge, gi = signals.load("Simulation/p1.c",'g') 
    614616        assert len(spikes) == 10 and len(vm) == 10 and len(ge) == 10 and len(gi) == 10 
    615617 
    616618    def testLoadSecondPopulationData(self): 
    617         spikes = signals.load(io.StandardPickleFile("Simulation/p2.spikes"),'s') 
    618         vm     = signals.load(io.StandardPickleFile("Simulation/p2.v"),'v') 
    619         ge     = signals.load(io.StandardPickleFile("Simulation/p2.c.ge"),'g') 
    620         gi     = signals.load(io.StandardPickleFile("Simulation/p2.c.gi"),'g') 
     619        spikes = signals.load("Simulation/p2.spikes",'s') 
     620        vm     = signals.load("Simulation/p2.v",'v') 
     621        ge, gi = signals.load("Simulation/p2.c",'g') 
    621622        assert len(spikes) == 10 and len(vm) == 10 and len(ge) == 10 and len(gi) == 10 
    622623