Skip to content

FIX : handle empty choices in Doc.get_golds() to prevent IndexError#1174

Open
nandeanie wants to merge 1 commit intohuggingface:mainfrom
nandeanie:fix/gold-index-out-of-range
Open

FIX : handle empty choices in Doc.get_golds() to prevent IndexError#1174
nandeanie wants to merge 1 commit intohuggingface:mainfrom
nandeanie:fix/gold-index-out-of-range

Conversation

@nandeanie
Copy link

Fixes #1162

Problem

When a generative task sets choices=[ ] with gold_index=0,
get_golds() raised an unhelpful IndexError: list index out of range.

Fix

Added a check in get_golds( ) to return empty list if choices is empty,
and a clear ValueError if gold_index is out of range.

Testing

Verified fix with:
doc = Doc(query='test', choices=[ ], gold_index=0)
doc.get_golds() # now returns [ ] instead of crashing

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.

[BUG] IndexError: list index out of rang

1 participant