Yao You 9191be7ae8
[issue 1237] fix empty coordinates break sorting bug (#1242)
This PR resolves #1237 by checking if any coordinates are `None`; if yes
do not attempt to sort with xy cut method and return the list as is.
2023-09-01 03:15:10 +00:00

11 lines
363 B
Python

import pytest
from unstructured.documents.elements import Element
from unstructured.partition.utils.sorting import sort_page_elements
@pytest.mark.parametrize("sort_mode", ["xy-cut", "basic"])
def test_sort_page_elements_without_coordinates(sort_mode):
elements = [Element(str(idx)) for idx in range(5)]
assert sort_page_elements(elements) == elements