def _make_datablock(self):
section_ids = sorted(self.sections)<EOL>id_to_insert_id = {}<EOL>row_count = <NUM_LIT:0><EOL>for section_id in section_ids:<EOL><INDENT>row_count += len(self.sections[section_id].points)<EOL>id_to_insert_id[section_id] = row_count - <NUM_LIT:1><EOL><DEDENT>datablock = np.empty((row_count, COLS.COL_COUNT), dtype=np.float)<EOL>datablock[:, COLS.ID] = np.arange(len(datablock))<EOL>datablock[:, COLS.P] = datablock[:, COLS.ID] - <NUM_LIT:1><EOL>sections = []<EOL>insert_index = <NUM_LIT:0><EOL>for id_ in section_ids:<EOL><INDENT>sec = self.sections[id_]<EOL>points, section_type, parent_id = sec.points, sec.section_type, sec.parent_id<EOL>idx = slice(insert_index, insert_index + len(points))<EOL>datablock[idx, COLS.XYZR] = points<EOL>datablock[idx, COLS.TYPE] = section_type<EOL>datablock[idx.start, COLS.P] = id_to_insert_id.get(parent_id, ROOT_ID)<EOL>sections.append(DataBlockSection(idx, section_type, parent_id))<EOL>insert_index = idx.stop<EOL><DEDENT>return datablock, sections<EOL>
Make a data_block and sections list as required by DataWrapper