From 745bd2f9494e554c504e391d07b5c7f5038353e0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:59:42 +0000 Subject: [PATCH 1/2] Fix warnings in test session and prevent index error" Fixes #585 index error list index out of range --- camelot/parsers/hybrid.py | 10 ++++------ noxfile.py | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/camelot/parsers/hybrid.py b/camelot/parsers/hybrid.py index bfa4cf38..2fa447e2 100644 --- a/camelot/parsers/hybrid.py +++ b/camelot/parsers/hybrid.py @@ -1,7 +1,5 @@ """Implementation of hybrid table parser.""" -import numpy as np - from ..utils import bboxes_overlap from ..utils import boundaries_to_split_lines from .base import BaseParser @@ -158,10 +156,10 @@ def _generate_table(self, table_idx, bbox, cols, rows, **kwargs): table = parser._generate_table(table_idx, bbox, cols, rows, **kwargs) # Because hybrid can inject extraneous splits from both lattice and # network, remove lines / cols that are completely empty. - table.df = table.df.replace("", np.nan) - table.df = table.df.dropna(axis=0, how="all") - table.df = table.df.dropna(axis=1, how="all") - table.df = table.df.replace(np.nan, "") + # drop empty rows + table.df = table.df.loc[~(table.df == "").all(axis=1)] + # drop empty columns + table.df = table.df.loc[:, ~(table.df == "").all(axis=0)] table.shape = table.df.shape return table diff --git a/noxfile.py b/noxfile.py index 6c502cfc..d93f5bb5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -190,7 +190,20 @@ def tests(session: Session) -> None: *plot_requires, ) try: - session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs) + session.run( + "coverage", + "run", + "--parallel", + "-m", + "pytest", + *session.posargs, + env={ + "PYTHONWARNINGS": ( + "ignore:ARC4 has been moved to" + " cryptography.hazmat.decrepit.ciphers.algorithms.ARC4" + ) + }, + ) finally: if session.interactive: session.notify("coverage", posargs=[]) From 2cb0a7b85004885cd0b6611dadd483afa6df859e Mon Sep 17 00:00:00 2001 From: bosd Date: Thu, 14 Aug 2025 16:45:00 +0200 Subject: [PATCH 2/2] Revert changes to noxfile.py --- noxfile.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/noxfile.py b/noxfile.py index d93f5bb5..6c502cfc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -190,20 +190,7 @@ def tests(session: Session) -> None: *plot_requires, ) try: - session.run( - "coverage", - "run", - "--parallel", - "-m", - "pytest", - *session.posargs, - env={ - "PYTHONWARNINGS": ( - "ignore:ARC4 has been moved to" - " cryptography.hazmat.decrepit.ciphers.algorithms.ARC4" - ) - }, - ) + session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs) finally: if session.interactive: session.notify("coverage", posargs=[])