Skip to content

Commit

Permalink
[REF] np.isclose to math.isclose
Browse files Browse the repository at this point in the history
  • Loading branch information
bosd committed Oct 14, 2024
1 parent 84692c8 commit 4c6720e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions camelot/parsers/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Defines a base parser. As well as generic methods for other parsers."""

import math
import os
import warnings

import numpy as np
import pandas as pd

from ..core import Table
Expand Down Expand Up @@ -321,7 +321,7 @@ def _group_rows(text, row_tol=2):
# if type(obj) is LTChar]):
if row_y is None:
row_y = t.y0
elif not np.isclose(row_y, t.y0, atol=row_tol):
elif not math.isclose(row_y, t.y0, abs_tol=row_tol):
rows.append(sorted(temp, key=lambda t: t.x0))
temp = []
# We update the row's bottom as we go, to be forgiving if there
Expand Down Expand Up @@ -354,8 +354,8 @@ def _merge_columns(cl, column_tol=0):
else:
lower = merged[-1]
if column_tol >= 0:
if higher[0] <= lower[1] or np.isclose(
higher[0], lower[1], atol=column_tol
if higher[0] <= lower[1] or math.isclose(
higher[0], lower[1], abs_tol=column_tol
):
upper_bound = max(lower[1], higher[1])
lower_bound = min(lower[0], higher[0])
Expand All @@ -364,7 +364,7 @@ def _merge_columns(cl, column_tol=0):
merged.append(higher)
elif column_tol < 0:
if higher[0] <= lower[1]:
if np.isclose(higher[0], lower[1], atol=abs(column_tol)):
if math.isclose(higher[0], lower[1], abs_tol=abs(column_tol)):
merged.append(higher)
else:
upper_bound = max(lower[1], higher[1])
Expand Down
3 changes: 2 additions & 1 deletion camelot/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""General helper utilities to parse the pdf tables."""

import atexit
import math
import os
import random
import re
Expand Down Expand Up @@ -856,7 +857,7 @@ def merge_close_lines(ar, line_tol=2):
ret.append(a)
else:
temp = ret[-1]
if np.isclose(temp, a, atol=line_tol):
if math.isclose(temp, a, abs_tol=line_tol):
temp = (temp + a) / 2.0
ret[-1] = temp
else:
Expand Down

0 comments on commit 4c6720e

Please sign in to comment.