Skip to content

fix tests for pandas v3#230

Open
pbsds wants to merge 1 commit into
Layout-Parser:mainfrom
pbsds:fix-pandas-v3
Open

fix tests for pandas v3#230
pbsds wants to merge 1 commit into
Layout-Parser:mainfrom
pbsds:fix-pandas-v3

Conversation

@pbsds

@pbsds pbsds commented Jul 13, 2026

Copy link
Copy Markdown

fixes

============================= test session starts ==============================
platform linux -- Python 3.14.6, pytest-9.0.3, pluggy-1.6.0
rootdir: /build/source
collected 27 items / 8 deselected / 19 selected

tests/test_elements.py ...........                                       [ 57%]
tests/test_io.py .F..                                                    [ 78%]
tests/test_ocr.py .                                                      [ 84%]
tests/test_tools.py ...                                                  [100%]

=================================== FAILURES ===================================
___________________________________ test_csv ___________________________________

    def test_csv():
        i = Interval(1, 2, "y", canvas_height=5)
        r = Rectangle(1, 2, 3, 4)
        q = Quadrilateral(np.arange(8).reshape(4, 2), 200, 400)
        l = Layout([i, r, q], page_data={"width": 200, "height": 200})

>       _l = load_csv("tests/fixtures/io/layout.csv")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_io.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/lib/python3.14/site-packages/layoutparser/io/basic.py:110: in load_csv
    return load_dataframe(pd.read_csv(filename), block_type=block_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/lib/python3.14/site-packages/layoutparser/io/basic.py:148: in load_dataframe
    return load_dict(df.apply(lambda x: x.dropna().to_dict(), axis=1).to_list())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/lib/python3.14/site-packages/layoutparser/io/basic.py:86: in load_dict
    return Layout([load_dict(ele) for ele in data])
                   ^^^^^^^^^^^^^^
/lib/python3.14/site-packages/layoutparser/io/basic.py:83: in load_dict
    return BASECOORD_ELEMENT_NAMEMAP[data["block_type"]].from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/lib/python3.14/site-packages/layoutparser/elements/base.py:274: in from_dict
    return cls(**{f: data[f] for f in cls._features})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'Quadrilateral' object has no attribute '_points'") raised in repr()] Quadrilateral object at 0x7fffbebba450>
points = '[0, 1, 2, 3, 4, 5, 6, 7]', height = 200.0, width = 400.0

    def __init__(
        self, points: Union[np.ndarray, List, List[List]], height=None, width=None
    ):

        if isinstance(points, np.ndarray):
            if points.shape != (4, 2):
                raise ValueError(f"Invalid points shape: {points.shape}.")
        elif isinstance(points, list):
            if len(points) == 8:
                points = np.array(points).reshape(4, 2)
            elif len(points) == 4 and isinstance(points[0], list):
                points = np.array(points)
            else:
                raise ValueError(
                    f"Invalid number of points element {len(points)}. Should be 8."
                )
        else:
>           raise ValueError(
                f"Invalid input type for points {type(points)}."
                "Please make sure it is a list of np.ndarray."
            )
E           ValueError: Invalid input type for points <class 'str'>.Please make sure it is a list of np.ndarray.

/lib/python3.14/site-packages/layoutparser/elements/layout_elements.py:829: ValueError

this may not be a full pandas v3 migration, but it fixes the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant