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

[BUG] Segment._split_cells doesn't handle non-unit characters well #3299

Open
rodrigogiraoserrao opened this issue Mar 7, 2024 · 0 comments · May be fixed by #3300
Open

[BUG] Segment._split_cells doesn't handle non-unit characters well #3299

rodrigogiraoserrao opened this issue Mar 7, 2024 · 0 comments · May be fixed by #3300
Labels
bug Something isn't working

Comments

@rodrigogiraoserrao
Copy link
Contributor

The classmethod Segment._split_cells uses a heuristic to start the search for the cut point that is too eager.
Because the algorithm implemented doesn't backtrack, one can construct example strings for which the cuts have the wrong sizes.

The two examples below show instances of the wrong result being computed.

s = Segment("🦊🦊🦊\n\n\n\n\n\n")
print(Segment._split_cells(s, 3))  # (Segment('🦊🦊🦊\n '), Segment(' \n\n\n\n'))

s = Segment("🦊🦊🦊abcdef")
print(Segment._split_cells(s, 3))  # (Segment('🦊🦊 '), Segment(' abcdef'))
@rodrigogiraoserrao rodrigogiraoserrao added the bug Something isn't working label Mar 7, 2024
@Textualize Textualize deleted a comment from github-actions bot Mar 7, 2024
rodrigogiraoserrao added a commit that referenced this issue Mar 7, 2024
We replace the linear search with a binary search like the one in cells.py::set_sell_size.
This doesn't seem to produce a significant impact in the performance of the method but it does fix bug #3299.
@rodrigogiraoserrao rodrigogiraoserrao linked a pull request Mar 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant