def _round_meta(pages):
    """Eliminate errors of floating point arithmetic for metadata."""
    for page in pages:
        anchors = page.anchors
        for anchor_name, (x1, y1, x2, y2) in anchors.items():
            anchors[anchor_name] = (
                round(x1, 6), round(y1, 6),
                round(x2, 6), round(y2, 6))
        links = page.links
        for i, link in enumerate(links):
            link_type, target, rectangle, box = link
            pos_x, pos_y, width, height = rectangle
            link = (
                link_type, target,
                (round(pos_x, 6), round(pos_y, 6),
                 round(width, 6), round(height, 6)),
                box)
            links[i] = link
        bookmarks = page.bookmarks
        for i, (level, label, (pos_x, pos_y), state) in enumerate(bookmarks):
            bookmarks[i] = (
                level, label, (round(pos_x, 6), round(pos_y, 6)), state)
Eliminate errors of floating point arithmetic for metadata.
tests/test_api.py