From cab65d1f11a18ebee7d55856de23af1ad5bc7eea Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 28 Oct 2016 00:31:04 -0700 Subject: [PATCH] pageinfo: add a python3.4 implementation of isclose() --- ocrmypdf/pageinfo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ocrmypdf/pageinfo.py b/ocrmypdf/pageinfo.py index 617f4bf7..216562a5 100644 --- a/ocrmypdf/pageinfo.py +++ b/ocrmypdf/pageinfo.py @@ -3,12 +3,20 @@ from subprocess import Popen, PIPE from decimal import Decimal, getcontext -from math import hypot, isclose +from math import hypot import re import sys import PyPDF2 as pypdf from collections import namedtuple +try: + from math import isclose +except ImportError: + def isclose(a, b, rel_tol=1e-9): + "Python 3.4 does not have math.isclose()" + diff = abs(b - a) + return diff <= abs(rel_tol * b) or diff <= abs(rel_tol * a) + matrix_mult = pypdf.pdf.utils.matrixMultiply FRIENDLY_COLORSPACE = {