Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit e1b16b0

Browse files
committed
[REF] Search header, closest_above
Split the search header method to reduce complexity.
1 parent 5b44b78 commit e1b16b0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

camelot/parsers/network.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ def search_header_from_body_bbox(body_bbox, textlines, col_anchors, max_v_gap):
151151
textline_center = 0.5 * (textline.x0 + textline.x1)
152152
if textline.y0 > top and left < textline_center < right:
153153
all_above.append(textline)
154-
if closest_above is None or closest_above.y0 > textline.y0:
155-
closest_above = textline
154+
closest_above = min(all_above, key=lambda tl: tl.y0, default=None)
156155

157156
if closest_above and closest_above.y0 < top + max_v_gap:
158157
# b/ We have a candidate cell that is within the correct

0 commit comments

Comments
 (0)