Changeset 1051
- Timestamp:
- 01/23/12 14:57:54 (4 months ago)
- Location:
- branches/neo_output
- Files:
-
- 3 modified
-
src/common/populations.py (modified) (3 diffs)
-
src/recording/__init__.py (modified) (4 diffs)
-
test/unittests/test_basepopulation.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/neo_output/src/common/populations.py
r1032 r1051 469 469 self.record(['gsyn_exc', 'gsyn_inh'], to_file) 470 470 471 def write_data(self, io, variables='all', gather=True ):471 def write_data(self, io, variables='all', gather=True, clear=False): 472 472 """ 473 473 Write recorded data to file, using one of the file formats supported by … … 483 483 file will be written on each node, containing only data from the cells 484 484 simulated on that node. 485 486 If `clear` is True, recorded data will be deleted from the `Population`. 485 487 """ 486 488 self.recorder.write(variables, io, gather, self.record_filter) 487 489 488 def get_data(self, variables='all', gather=True ):490 def get_data(self, variables='all', gather=True, clear=False): 489 491 """ 490 492 Return a Neo `Block` containing the data (spikes, state variables) … … 499 501 Otherwise, the Neo `Block` will contain only data from the cells 500 502 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) 503 507 504 508 @deprecated("write_data(file, 'spikes')") -
branches/neo_output/src/recording/__init__.py
r1034 r1051 135 135 self._data.append(obj) 136 136 137 def clear(self): 138 self._data = [] 139 137 140 138 141 class Recorder(object): … … 180 183 return self.recorded[variable] 181 184 182 def get(self, variables, gather=False, filter_ids=None ):185 def get(self, variables, gather=False, filter_ids=None, clear=False): 183 186 """Return the recorded data as a Neo `Block`.""" 184 187 variables = normalize_variables_arg(variables) … … 194 197 if gather and self._simulator.state.num_processes > 1: 195 198 data = gather_array(data) 199 if clear: 200 self.cache.clear() 196 201 return data 197 202 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): 199 204 """Write recorded data to a Neo IO""" 200 205 io = file or self.file … … 203 208 logger.debug("Recorder is writing '%s' to file '%s' with gather=%s" % ( 204 209 variables, io.filename, gather)) 205 data = self.get(variables, gather, filter_ids )210 data = self.get(variables, gather, filter_ids, clear) 206 211 if self._simulator.state.mpi_rank == 0 or gather == False: 207 212 # Open the output file, if necessary and write the data -
branches/neo_output/test/unittests/test_basepopulation.py
r1008 r1051 368 368 meth, args, kwargs = p.recorder.method_calls[0] 369 369 assert_equal(meth, 'get') 370 assert_equal(args, ("spikes", "gather", "filter" ))370 assert_equal(args, ("spikes", "gather", "filter", False)) 371 371 372 372 def test_print_v(): … … 386 386 meth, args, kwargs = p.recorder.method_calls[0] 387 387 assert_equal(meth, 'get') 388 assert_equal(args, ("v", "gather", "filter" ))388 assert_equal(args, ("v", "gather", "filter", False)) 389 389 390 390 def test_print_gsyn(): … … 404 404 meth, args, kwargs = p.recorder.method_calls[0] 405 405 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)) 407 407 408 408 def test_get_spike_counts():
