Spaces:
Sleeping
Sleeping
Download repro_error.py from rianders/pdfinspector: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/rianders/pdfinspector/resolve/main/repro_error.py
- Command line
-
hf download hf://spaces/rianders/pdfinspector/repro_error.py
-
curl -L -o repro_error.py https://huggingface.co/spaces/rianders/pdfinspector/resolve/main/repro_error.py
1.07 kB
| import pymupdf as fitz | |
| from layout_utils import extract_blocks_spans | |
| def test_extraction(): | |
| # Open the real PDF | |
| doc = fitz.open("logic.pdf") | |
| # doc.new_page() ... no | |
| # Analyze it using the function I modified | |
| try: | |
| blocks = extract_blocks_spans(doc, 0) | |
| print(f"Blocks extracted: {len(blocks)}") | |
| for i, b in enumerate(blocks): | |
| bbox = b.bbox | |
| print(f"Block {i} bbox type: {type(bbox)}") | |
| if isinstance(bbox, tuple): | |
| print(f"Block {i} bbox len: {len(bbox)}") | |
| if len(bbox) == 4: | |
| print(f"Block {i} sample: {bbox}") | |
| # Try unpacking | |
| x0, y0, x1, y1 = bbox | |
| # Try explicit float cast | |
| _ = float(x0) | |
| else: | |
| print(f"Block {i} bbox is NOT tuple: {bbox}") | |
| except Exception as e: | |
| print(f"Error caught: {type(e).__name__}: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| if __name__ == "__main__": | |
| test_extraction() | |