Skip to content

Commit

Permalink
fix: list index out of range error caused by calling LayoutElements.f…
Browse files Browse the repository at this point in the history
…rom_list() with empty list (#398)

error coming from
https://github.com/Unstructured-IO/core-product/actions/runs/11510770484/job/32043653203?pr=662#step:5:718
or lmk if there are better way to fix error w/o changing here :)
  • Loading branch information
yuming-long authored Oct 25, 2024
1 parent 7b43309 commit 4309e9e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
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

0 comments on commit 4309e9e

Please sign in to comment.