Changeset 1051

Show
Ignore:
Timestamp:
01/23/12 14:57:54 (4 months ago)
Author:
apdavison
Message:

Previous commit was in wrong directory. Here are the rest of the changes.

Location:
branches/neo_output
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/neo_output/src/common/populations.py

    r1032 r1051  
    469469        self.record(['gsyn_exc', 'gsyn_inh'], to_file) 
    470470 
    471     def write_data(self, io, variables='all', gather=True): 
     471    def write_data(self, io, variables='all', gather=True, clear=False): 
    472472        """ 
    473473        Write recorded data to file, using one of the file formats supported by 
     
    483483        file will be written on each node, containing only data from the cells 
    484484        simulated on that node. 
     485         
     486        If `clear` is True, recorded data will be deleted from the `Population`. 
    485487        """ 
    486488        self.recorder.write(variables, io, gather, self.record_filter) 
    487489 
    488     def get_data(self, variables='all', gather=True): 
     490    def get_data(self, variables='all', gather=True, clear=False): 
    489491        """ 
    490492        Return a Neo `Block` containing the data (spikes, state variables) 
     
    499501        Otherwise, the Neo `Block` will contain only data from the cells 
    500502        simulated on the local node. 
    501         """ 
    502         return self.recorder.get(variables, gather, self.record_filter) 
     503         
     504        If `clear` is True, recorded data will be deleted from the `Population`. 
     505        """ 
     506        return self.recorder.get(variables, gather, self.record_filter, clear) 
    503507 
    504508    @deprecated("write_data(file, 'spikes')") 
  • branches/neo_output/src/recording/__init__.py

    r1034 r1051  
    135135            self._data.append(obj) 
    136136 
     137    def clear(self): 
     138        self._data = [] 
     139 
    137140 
    138141class Recorder(object): 
     
    180183            return self.recorded[variable] 
    181184     
    182     def get(self, variables, gather=False, filter_ids=None): 
     185    def get(self, variables, gather=False, filter_ids=None, clear=False): 
    183186        """Return the recorded data as a Neo `Block`.""" 
    184187        variables = normalize_variables_arg(variables) 
     
    194197        if gather and self._simulator.state.num_processes > 1: 
    195198            data = gather_array(data) 
     199        if clear: 
     200            self.cache.clear() 
    196201        return data 
    197202     
    198     def write(self, variables, file=None, gather=False, filter_ids=None): 
     203    def write(self, variables, file=None, gather=False, filter_ids=None, clear=False): 
    199204        """Write recorded data to a Neo IO""" 
    200205        io = file or self.file 
     
    203208        logger.debug("Recorder is writing '%s' to file '%s' with gather=%s" % ( 
    204209                                               variables, io.filename, gather)) 
    205         data = self.get(variables, gather, filter_ids) 
     210        data = self.get(variables, gather, filter_ids, clear) 
    206211        if self._simulator.state.mpi_rank == 0 or gather == False: 
    207212            # Open the output file, if necessary and write the data 
  • branches/neo_output/test/unittests/test_basepopulation.py

    r1008 r1051  
    368368    meth, args, kwargs = p.recorder.method_calls[0] 
    369369    assert_equal(meth, 'get') 
    370     assert_equal(args, ("spikes", "gather", "filter")) 
     370    assert_equal(args, ("spikes", "gather", "filter", False)) 
    371371 
    372372def test_print_v(): 
     
    386386    meth, args, kwargs = p.recorder.method_calls[0] 
    387387    assert_equal(meth, 'get') 
    388     assert_equal(args, ("v", "gather", "filter")) 
     388    assert_equal(args, ("v", "gather", "filter", False)) 
    389389     
    390390def test_print_gsyn(): 
     
    404404    meth, args, kwargs = p.recorder.method_calls[0] 
    405405    assert_equal(meth, 'get') 
    406     assert_equal(args, (["gsyn_exc", "gsyn_inh"], "gather", "filter")) 
     406    assert_equal(args, (["gsyn_exc", "gsyn_inh"], "gather", "filter", False)) 
    407407     
    408408def test_get_spike_counts():