Files
docling/tests/test_layout_postprocessor.py
geoHeil 5b1df788ef ci: tighten pre-commit guardrails (#3346)
* ci: tighten pre-commit guardrails

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: validate pre-commit guardrail changes

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: switch hook validation to prek

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: exempt active slim plan from max-lines

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: move max-lines config under github

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: fail on uncovered tach modules

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: ignore generated docs in max-lines check

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: clarify local validation tasks

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* docs: refine agent instructions

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: replace mypy with ty

(cherry picked from commit 382afbde8f00abfaeba95ea9c8e9cc603f27a2d9)
Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

* ci: replace justfile with makefile

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>

---------

Signed-off-by: Georg Heiler <georg.kf.heiler@gmail.com>
2026-05-08 15:07:11 +02:00

33 lines
842 B
Python

from docling_core.types.doc.page import BoundingRectangle, TextCell
from docling.utils.layout_postprocessor import LayoutPostprocessor
def _text_cell(index: int) -> TextCell:
return TextCell(
index=index,
rect=BoundingRectangle(
r_x0=0,
r_y0=0,
r_x1=1,
r_y1=0,
r_x2=1,
r_y2=1,
r_x3=0,
r_y3=1,
),
text=str(index),
orig=str(index),
from_ocr=False,
)
def test_sort_cells_uses_native_cell_index_order() -> None:
processor = object.__new__(LayoutPostprocessor)
cells = [_text_cell(3), _text_cell(1), _text_cell(2)]
sorted_cells = processor._sort_cells(cells)
assert [cell.index for cell in sorted_cells] == [1, 2, 3]
assert [cell.index for cell in cells] == [3, 1, 2]