'Add data into buffer i.'

def AddToBuffer(self, i, data):

    buf = self.buffers[i]
    buf_index = self.buffer_index[i]
    datasize = data.shape[0]
    assert ((datasize + buf_index) <= buf.shape[0]), 'Not    enough    space    in    buffer.'
    buf[buf_index:(buf_index + datasize)] = data
    self.buffer_index[i] += datasize
