# Buggy code
def get_figures(boxes, page_bbox, page_num, boxes_figures, page_width, page_height):
    if len(boxes) == 0:
        log.warning("No boxes to get figures from on page {}.".format(page_num))
        return []

    plane = Plane(page_bbox)
    plane.extend(boxes)

    nodes_figures = []

    for fig_box in boxes_figures:
        node_fig = Node(fig_box)
        nodes_figures.append(node_fig)

    merge_indices = [i for i in range(len(nodes_figures))]
    page_stat = Node(boxes)
    nodes, merge_indices = merge_nodes(nodes_figures, plane, page_stat, merge_indices)

    ##Merging Nodes
    new_nodes = []
    for idx in range(len(merge_indices)):
        if merge_indices[idx] == idx:
            new_nodes.append(nodes[idx])

    figures = [
        (page_num, page_width, page_height) + (node.y0, node.x0, node.y1, node.x1)
        for node in new_nodes
    ]
    return figures


# Traceback (ValueError)
Digitized PDF detected, building tree structure
float division by zero
float division by zero
float division by zero
(89.33853599999992, 89.33853599999992, 50)
Traceback (most recent call last):
File "chh_test.py", line 10, in <module>
pdftotree.parse(filename, htmlpath, model_path=None, favor_figures=False, visualize=True)
File "/home/chhenning/repos/pdftotree/pdftotree/core.py", line 57, in parse
pdf_tree = extractor.get_tree_structure(model, favor_figures)
File "/home/chhenning/repos/pdftotree/pdftotree/TreeExtract.py", line 195, in get_tree_structure
favor_figures)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/pdf_parsers.py", line 615, in parse_tree_structure
figures_page = get_figures(mentions, elems.layout.bbox, page_num, boxes_figures, page_width, page_height)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/pdf_parsers.py", line 945, in get_figures
page_stat = Node(boxes)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/node.py", line 44, in __init__
self.set_bbox(bound_elems(elems))
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/vector_utils.py", line 101, in bound_elems
group_x0 = min(map(lambda l:l.x0,elems))
ValueError: min() arg is an empty sequence

# Fixed code
def get_figures(boxes, page_bbox, page_num, boxes_figures, page_width, page_height):
    # Filter out boxes with zero width or height
    filtered_boxes = []
    for bbox in boxes:
        if bbox.x1 - bbox.x0 > 0 and bbox.y1 - bbox.y0 > 0:
            filtered_boxes.append(bbox)
    boxes = filtered_boxes

    if len(boxes) == 0:
        log.warning("No boxes to get figures from on page {}.".format(page_num))
        return []

    plane = Plane(page_bbox)
    plane.extend(boxes)

    nodes_figures = []

    for fig_box in boxes_figures:
        node_fig = Node(fig_box)
        nodes_figures.append(node_fig)

    merge_indices = [i for i in range(len(nodes_figures))]
    page_stat = Node(boxes)
    nodes, merge_indices = merge_nodes(nodes_figures, plane, page_stat, merge_indices)

    ##Merging Nodes
    new_nodes = []
    for idx in range(len(merge_indices)):
        if merge_indices[idx] == idx:
            new_nodes.append(nodes[idx])

    figures = [
        (page_num, page_width, page_height) + (node.y0, node.x0, node.y1, node.x1)
        for node in new_nodes
    ]
    return figures