Repository navigation
Conversation
TableData.remove_rows sliced table_cells by position (row_index * num_cols). That assumes a dense, row-major cell list. A table with a spanning cell holds fewer cells than num_rows * num_cols, so the slice took cells of the following rows and the renumbering step rewrote every row offset by list position. The removed row then held foreign cells and the grid mixed content of different rows. Select the cells by their row offsets instead, and shrink the row span of a cell that only partly covers the removed row. The result matches the previous behaviour for dense tables. Signed-off-by: simpleqt <89645338+simpleqt@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @simpleqt, all your commits are properly signed off. 🎉 |
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TableData.remove_rows()selected the cells of a row withtable_cells[row_index * num_cols : (row_index + 1) * num_cols]and then rewrote the row offsets of the surviving cells withindex // num_cols. Both steps assume thattable_cellsis a dense, row-major array.A table with a spanning cell has fewer cells than
num_rows * num_cols, so for such a table the slice returns cells of the following rows and the renumbering destroys the offsets of the remaining cells.How
Select the cells by their row offsets. A cell that lives in the removed row only is removed; a cell that only partly covers the removed row keeps its content and its row span shrinks by one; cells below the removed row shift both row offsets by one. The position-based renumbering loop is removed, so column spans and column offsets survive.
Repro (before)
A 3x2 table whose row 0 is one header cell spanning both columns:
After the fix:
removed == [['SPAN']],grid == [['r1c0', 'r1c1'], ['r2c0', 'r2c1']].Tests
tests/test_docling_doc.py::test_table_remove_rows_keeps_spanning_cells(fails onmain, passes with the fix). Dense tables keep their previous behaviour:remove_rows([1, 1])on a 4x2 table is unchanged.