fix(tables): keep every header row when the column header starts below the first row
align_headers in unstructured_inference/models/tables.py:487 fills in the rows above a column header with range(header_row_nums[0] + 1), so the first header row appears twice. The loop that follows stops at the repeat. Every header row after the first one then comes out as a body row. In cells_to_html that row turns into <td> cells in <tbody>, so text_as_html loses the second header row.
A header box over rows 1 and 2 of a four-row table:
$ python align_demo.py # at 158db67
[{'bbox': [0, 0, 100, 20]}]
[True, True, False, False]
With range(header_row_nums[0]):
$ python align_demo.py
[{'bbox': [0, 0, 100, 30]}]
[True, True, True, False]
The docstring asks for the convex hull of the rows the header intersects. The code extends that up to row 0, so rows 0 to 2 here. A header that starts on row 0, or covers a single row, gives the same result before and after. The line came from microsoft/table-transformer's postprocess.py, and that repository is archived, so this copy is the only place to fix it. No issue exists for this.
Verification
$ python -m pytest -q test_unstructured_inference/models/test_tables.py
60 passed in 13.47s
Baseline on 158db67 is 57 passed, so the delta is the 3 new cases. I restored tables.py from 158db67 and kept the tests, which gives 1 failed, 59 passed. The failing case is the header over rows 1 and 2. ruff check and ruff format --check (0.15.10) are clean on both files, and make check-version passes.
# not run: the rest of test_unstructured_inference, which loads the detection models
The CHANGELOG entry takes 1.6.15, which my #525 also claims. I'll rebase whichever one merges second. @badGarnet, could you review this when you next look at table post-processing?