Skip to content

handle edge cases in balanced_truncate#328

Open
ashala-senanayake wants to merge 1 commit into
thunlp:mainfrom
ashala-senanayake:truncate-error-handling
Open

handle edge cases in balanced_truncate#328
ashala-senanayake wants to merge 1 commit into
thunlp:mainfrom
ashala-senanayake:truncate-error-handling

Conversation

@ashala-senanayake

Copy link
Copy Markdown

#327

The updated version includes the following improvements:

  • Safe access to list elements - Ensures parts is non-empty before checking parts[0] == 1.
  • Zero-length handling - Adds a check to avoid division by zero when total_shortenable_len == 0.
  • Safe truncation - Uses max(..., 0) to prevent negative slicing.
  • Cleaner output - Filters out empty parts after truncation to produce a cleaner, more usable output.

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.

1 participant