def get_cell_distribution_of_block(tags: 'np.array[CellTypePMF]', block: SimpleBlock): count = dict() for i in range(block.get_top_row(), block.get_bottom_row() + 1): for j in range(block.get_left_col(), block.get_right_col() + 1): tag = tags[i][j].get_best_type() if tag not in count: count[tag] = 0 count[tag] += 1 return count
def get_splits(self, block: SimpleBlock, row_h, col_h): for row in row_h: # if row >= block.get_top_row() and row < block.get_bottom_row(): if block.get_top_row() <= row < block.get_bottom_row(): b1 = SimpleBlock(None, block.get_left_col(), block.get_right_col(), block.get_top_row(), row) b2 = SimpleBlock(None, block.get_left_col(), block.get_right_col(), row + 1, block.get_bottom_row()) yield b1, b2 for col in col_h: # if col >= block.get_left_col() and col < block.get_right_col(): if block.get_left_col() <= col < block.get_right_col(): b1 = SimpleBlock(None, block.get_left_col(), col, block.get_top_row(), block.get_bottom_row()) b2 = SimpleBlock(None, col + 1, block.get_right_col(), block.get_top_row(), block.get_bottom_row()) yield b1, b2