From 44ef15b10f9f79c8a892271f0a47f3417c355d1d Mon Sep 17 00:00:00 2001 From: Menna Ayman Date: Sat, 25 Apr 2026 18:41:49 +0300 Subject: [PATCH 1/3] Change iou function to work with PyMuPDF Rect intialization --- src/grits.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grits.py b/src/grits.py index c9d48280e..c405e3352 100644 --- a/src/grits.py +++ b/src/grits.py @@ -226,8 +226,8 @@ def iou(bbox1, bbox2): """ Compute the intersection-over-union of two bounding boxes. """ - intersection = Rect(bbox1).intersect(bbox2) - union = Rect(bbox1).include_rect(bbox2) + intersection = Rect(list(bbox1)).intersect(list(bbox2)) + union = Rect(list(bbox1)).include_rect(list(bbox2)) union_area = union.get_area() if union_area > 0: From bad79db94488f186047312e7d705b55dc0655163 Mon Sep 17 00:00:00 2001 From: Menna Ayman Date: Sat, 25 Apr 2026 18:47:38 +0300 Subject: [PATCH 2/3] Change cells_to_relspan_grid cell_grid intialization to a list of four zeroes Co-authored-by: Copilot --- src/grits.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grits.py b/src/grits.py index c405e3352..a2a6b3ec0 100644 --- a/src/grits.py +++ b/src/grits.py @@ -267,7 +267,7 @@ def cells_to_relspan_grid(cells): return [[]] num_rows = max([max(cell['row_nums']) for cell in cells])+1 num_columns = max([max(cell['column_nums']) for cell in cells])+1 - cell_grid = np.zeros((num_rows, num_columns)).tolist() + cell_grid = [[[0, 0, 0, 0] for _ in range(num_columns)] for _ in range(num_rows)] for cell in cells: min_row_num = min(cell['row_nums']) min_column_num = min(cell['column_nums']) From 0b907d4e03e22af13274e818f07f8631f96992ce Mon Sep 17 00:00:00 2001 From: Menna Ayman Date: Sat, 25 Apr 2026 19:22:55 +0300 Subject: [PATCH 3/3] Change cell_grid intialization in cells_to_grid --- src/grits.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grits.py b/src/grits.py index a2a6b3ec0..c919f6004 100644 --- a/src/grits.py +++ b/src/grits.py @@ -249,7 +249,7 @@ def cells_to_grid(cells, key='bbox'): return [[]] num_rows = max([max(cell['row_nums']) for cell in cells])+1 num_columns = max([max(cell['column_nums']) for cell in cells])+1 - cell_grid = np.zeros((num_rows, num_columns)).tolist() + cell_grid = [["" for _ in range(num_columns)] for _ in range(num_rows)] for cell in cells: for row_num in cell['row_nums']: for column_num in cell['column_nums']: