Skip to content

fix: avoid divide-by-zero in code composition tagger#305

Open
Chessing234 wants to merge 1 commit into
allenai:mainfrom
Chessing234:fix/code-composition-empty-doc
Open

fix: avoid divide-by-zero in code composition tagger#305
Chessing234 wants to merge 1 commit into
allenai:mainfrom
Chessing234:fix/code-composition-empty-doc

Conversation

@Chessing234

Copy link
Copy Markdown

Summary

  • return early when class_counts is empty before computing label percentages

Whitespace-only docs never populate class_counts, so sum(class_counts.values()) was 0 and the pct loop crashed.

Test plan

  • run code composition tagger on an empty/whitespace document and confirm it returns boundary score only

Made with Cursor

Empty or whitespace-only docs left class_counts empty and blew up on
division by zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
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