table-transformer icon indicating copy to clipboard operation
table-transformer copied to clipboard

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (12, 4) + inhomogeneous part.

Open bang123-box opened this issue 3 months ago • 0 comments

in the grits.py file, when the code meet "pred_topology_grid = np.array(cells_to_relspan_grid(pred_cells))", some error occurs: ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (12, 4) + inhomogeneous part. ` def grits_from_html(true_html, pred_html): """ Compute GriTS_Con and GriTS_Top for two HTML sequences. """

metrics = {}
true_cells = html_to_cells(true_html)
pred_cells = html_to_cells(pred_html)
# Convert lists of cells to matrices of grid cells
true_topology_grid = np.array(cells_to_relspan_grid(true_cells))
pred_topology_grid = np.array(cells_to_relspan_grid(pred_cells))
true_text_grid = np.array(cells_to_grid(true_cells, key='cell_text'), dtype=object)
pred_text_grid = np.array(cells_to_grid(pred_cells, key='cell_text'), dtype=object)

grits_con, grits_precision_con, grits_recall_con,grits_con_upper_bound = grits_con(true_text_grid, pred_text_grid)

return grits_con, grits_precision_con, grits_recall_con,grits_con_upper_bound`

I suspect this issue might be caused by an inconsistent number of cells per row in my pred_html, which leads to some empty cells in the resulting grid. I was wondering if this scenario was considered when the metric was designed.

bang123-box avatar Sep 23 '25 12:09 bang123-box