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 sort_page_element. ensures that sorting is stable and not random. #3978

Merged

Conversation

pprados
Copy link
Contributor

@pprados pprados commented Apr 3, 2025

The sort_page_element() use the element id to sort the elements.
Two executions of the same code, on the same file, produce different results. The order of the elements is random.
This makes it impossible to write stable unit tests, for example, or to obtain reproducible results.

@pprados pprados force-pushed the pprados/fix-sort-page-elements branch from 73f713a to 0e4da68 Compare April 3, 2025 09:15
@pprados pprados marked this pull request as ready for review April 3, 2025 09:36
@badGarnet
Copy link
Collaborator

Hi @pprados could you please write up a unit test that:

  • reproduces the issue you discovered without the fix
  • test passes with the fix
    Thanks!

@pprados pprados force-pushed the pprados/fix-sort-page-elements branch from 4534f07 to ca263ec Compare April 7, 2025 14:39
pprados added 3 commits April 7, 2025 16:39
…into pprados/fix-sort-page-elements

# Conflicts:
#	test_unstructured/partition/pdf_image/test_pdf.py
@pprados
Copy link
Contributor Author

pprados commented Apr 7, 2025

done.
You can remove the fix in sorting.py to see the bug.

@badGarnet badGarnet added this pull request to the merge queue Apr 7, 2025
@badGarnet
Copy link
Collaborator

done. You can remove the fix in sorting.py to see the bug.

approved. Thanks for the contribution!

Merged via the queue into Unstructured-IO:main with commit d570f46 Apr 7, 2025
43 checks passed
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.

2 participants