Fix ocrd workspace list-page: page ranges #1145
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problematic example case: 25 pages, 8 chunks -> 3,125 pages per chunk, the chunk should contain 3 pages, but contains 4 (due to the ceil method used), which makes the 7th chunk (chunk index 6) having only the 25th page, and the 8th chunk (chunk index 7) being empty which triggers an exception. Using the floor method would introduce other errors such as page overflowing (e.g., 3 pages per chunk is 24 pages, and the 25th page is lost).
Simply using NumPy, prevents such edge cases.
Old output range: [[1, 2, 3, 4], [5, 6, 7, 8],..., [21, 22, 23, 24], [25]]
New output range: [[1, 2, 3, 4], [5, 6, 7],..., [20, 21, 22], [23, 24, 25]]
Of course, it is also possible to have chunks divided based on leaps, e.g. [1]:
would produce:
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12, 13], [14, 15, 16], [17, 18, 19], [20, 21, 22], [23, 24, 25]]