Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: list index out of range error caused by calling LayoutElements.from_list() with empty list #398

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.8.1
* fix: fix list index out of range error caused by calling LayoutElements.from_list() with empty list

## 0.8.0

* fix: fix missing source after cleaning layout elements
Expand Down
5 changes: 5 additions & 0 deletions test_unstructured_inference/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,8 @@ def test_layoutelements_to_list_and_back(test_layoutelements):
test_layoutelements.element_class_id_map[idx]
for idx in test_layoutelements.element_class_ids
] == [back.element_class_id_map[idx] for idx in back.element_class_ids]


def test_layoutelements_from_list_no_elements():
back = LayoutElements.from_list(elements=[])
assert back.source is None
2 changes: 1 addition & 1 deletion unstructured_inference/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.0" # pragma: no cover
__version__ = "0.8.1" # pragma: no cover
2 changes: 1 addition & 1 deletion unstructured_inference/inference/layoutelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def from_list(cls, elements: list):
element_probs=np.array(class_probs),
element_class_ids=class_ids,
element_class_id_map=dict(zip(range(len(unique_ids)), unique_ids)),
source=elements[0].source,
source=elements[0].source if len_ele else None,
)


Expand Down
Loading