def test__make_compatible_v(): r = recording.Recorder('v') input_data = numpy.array([[0, 0.0, -65.0], [3, 0.0, -65.0], [0, 0.1, -64.3], [3, 0.1, -65.1], [0, 0.2, -63.7], [3, 0.2, -65.5]]) output_data = r._make_compatible(input_data) # voltage id assert_arrays_equal(input_data[:, (2, 0)], output_data)
def test_metadata_property(): r = recording.Recorder('spikes', population=None) r._get = Mock(return_value=numpy.random.uniform(size=(6, 2))) assert_equal(r.metadata, {'variable': 'spikes', 'dt': 0.123, 'n': 6}) r = recording.Recorder('v', population=MockPopulation()) r._get = Mock(return_value=numpy.random.uniform(size=(6, 2))) assert_equal( r.metadata, { 'first_id': 2454, 'label': 'mock population', 'n': 6, 'variable': 'v', 'dt': 0.123, 'last_id': 2465, 'size': 11, 'first_index': 0, 'last_index': 11 })
def test_write__with_filename__compatible_output__gather__onroot(): orig_metadata = recording.Recorder.metadata recording.Recorder.metadata = {'a': 2, 'b': 3} r = recording.Recorder('spikes') fake_data = numpy.array([(3, 12.3), (4, 14.5), (7, 19.8)]) r._get = Mock(return_value=fake_data) r._make_compatible = Mock(return_value=fake_data) r.write(file="tmp.spikes", gather=True, compatible_output=True) os.remove("tmp.spikes") recording.Recorder.metadata = orig_metadata
def test_filter_recorded(): r = recording.Recorder('spikes') r._record = Mock() all_ids = (MockID(0, True), MockID(1, False), MockID(2, True), MockID(3, True), MockID(4, False)) r.record(all_ids) assert_equal(r.recorded, set(id for id in all_ids if id.local)) filter = all_ids[::2] filtered_ids = r.filter_recorded(filter) assert_equal(filtered_ids, set(id for id in filter if id.local)) assert_equal(r.filter_recorded(None), r.recorded)
def test_record(): r = recording.Recorder('spikes') r._record = Mock() assert_equal(r.recorded, set([])) all_ids = (MockID(0, True), MockID(1, False), MockID(2, True), MockID(3, True), MockID(4, False)) first_ids = all_ids[0:3] r.record(first_ids) assert_equal(r.recorded, set(id for id in first_ids if id.local)) assert_equal(len(r.recorded), 2) r._record.assert_called_with(r.recorded) more_ids = all_ids[2:5] r.record(more_ids) assert_equal(r.recorded, set(id for id in all_ids if id.local)) assert_equal(len(r.recorded), 3) r._record.assert_called_with(set(all_ids[3:4]))
def test_Recorder_create(): r = recording.Recorder('spikes') assert_equal(r.variable, 'spikes') assert_equal(r.population, None) assert_equal(r.file, None) assert_equal(r.recorded, set([]))
def test__make_compatible_spikes(): r = recording.Recorder('spikes') input_data = numpy.array([[0, 12.3], [1, 45.2], [0, 46.3], [4, 49.4], [0, 78.3]]) output_data = r._make_compatible(input_data) # time id assert_arrays_equal(input_data[:, (1, 0)], output_data)
def test_get__zero_offset(): r = recording.Recorder('spikes') fake_data = numpy.array([(3, 12.3), (4, 14.5), (7, 19.8)]) r._get = Mock(return_value=fake_data) assert_arrays_equal(r.get(), fake_data)