Create a new block with the :code:`parent_idx` and change the current block to new block. Args: parent_idx(int): The parent block index. Returns: Block: The new block.
(self, parent_idx=None)
| 7291 | return self.blocks[self.current_block_idx] |
| 7292 | |
| 7293 | def _create_block(self, parent_idx=None): |
| 7294 | """ |
| 7295 | Create a new block with the :code:`parent_idx` and change the current block |
| 7296 | to new block. |
| 7297 | |
| 7298 | Args: |
| 7299 | |
| 7300 | parent_idx(int): The parent block index. |
| 7301 | |
| 7302 | Returns: |
| 7303 | Block: The new block. |
| 7304 | """ |
| 7305 | new_block_idx = len(self.blocks) |
| 7306 | parent = ( |
| 7307 | self.current_block() |
| 7308 | if parent_idx is None |
| 7309 | else self.block(parent_idx) |
| 7310 | ) |
| 7311 | self.desc.append_block(parent.desc) |
| 7312 | self.current_block_idx = new_block_idx |
| 7313 | self.blocks.append(Block(self, self.current_block_idx)) |
| 7314 | return self.current_block() |
| 7315 | |
| 7316 | def _roll_to_global_block(self): |
| 7317 | self.current_block_idx = 0 |