def testCreateEmptyTable(self): return_value = utils.CreateEmptyTable(5, 10) json_data = json.loads(return_value) self.assertEqual([{ 'id': 'seconds', 'label': 'seconds', 'type': 'number' }], json_data['cols']) self.assertEqual([{ 'c': [{ 'v': 0 }] }, { 'c': [{ 'v': 1 }] }, { 'c': [{ 'v': 2 }] }, { 'c': [{ 'v': 3 }] }, { 'c': [{ 'v': 4 }] }, { 'c': [{ 'v': 5 }] }], json_data['rows'])
def GetMetadata(data_source, max_samples): """Returns metadata consistent across the predictions. Args: data_source: The DataSource for the waveform data. max_samples: The maximum number of samples in one channel response. Returns: A PredictionMetadata instance filled with PredictionOutput data. """ response = data_pb2.WaveformMetadata() response.abs_start = data_source.GetStartTime() response.labels.extend(data_source.GetAnnotations()) for index, channel in data_source.GetChannelIndexDict().iteritems(): response.channel_dict[index] = channel response.file_type = data_source.GetFileType() response.nav_timeline_datatable = utils.CreateEmptyTable( data_source.GetLength(), max_samples) response.num_secs = data_source.GetLength() response.patient_id = data_source.GetPatientId() response.sstable_key = data_source.GetFileKey() return response