added numpy export

This commit is contained in:
ari committed 2020-11-06 14:02:33 -05:00
1 parent 69d562ce19
commit 00d8fe72d8
2 files changed
+17 -1

No files matched your search

+16
View File
@@ -1,6 +1,8 @@
from decimal import Decimal from decimal import Decimal
from typing import List, NamedTuple from typing import List, NamedTuple
import numpy as np
from pdfmajor.document.exceptions import BrokenFilePDF, TooManyRectField from pdfmajor.document.exceptions import BrokenFilePDF, TooManyRectField
from pdfmajor.pdf_parser.objects import PDFArray, PDFInteger, PDFReal from pdfmajor.pdf_parser.objects import PDFArray, PDFInteger, PDFReal
@@ -30,3 +32,17 @@ class PDFRectangle(NamedTuple):
f"Insufficient number of fields for rectangle {arr} {vals}" f"Insufficient number of fields for rectangle {arr} {vals}"
) )
return cls(*vals) return cls(*vals)
def to_numpy(self) -> np.ndarray:
"""convert the rectangle to a numpy array
Returns:
np.ndarray[np.float64]
"""
return np.array(
[
[np.float64(self.llx), np.float64(self.lly)],
[np.float64(self.urx), np.float64(self.ury)],
],
dtype=np.float64,
)
+1 -1
View File
@@ -12,7 +12,7 @@ with open("README.md") as readme_file:
"name": "pdfmajor", "name": "pdfmajor",
"version": "1.3.13", "version": "1.3.13",
"packages": find_packages(include=["pdfmajor*"]), "packages": find_packages(include=["pdfmajor*"]),
"install_requires": ["numpy==1.19.4", "typing-extensions==3.7.4.3"], "install_requires": ["numpy==1.19.4", "data-science-types==0.2.19"],
"extras_require": { "extras_require": {
"dev": [ "dev": [
"tqdm==4.32.1", "tqdm==4.32.1",