fix: resolve ZeroDivisionError and NameError in OpenAICloseSetClsEvaluator.print_results#75
Open
octo-patch wants to merge 1 commit intoInternRobotics:masterfrom
Conversation
…uator.print_results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
OpenAICloseSetClsEvaluator.print_results()inpointllm/eval/evaluator.pycontains two bugs that cause crashes whentotal_predictions == 0(e.g. evaluation on an empty result set):ZeroDivisionError: A stray
accuracy = self.correct_predictions / self.total_predictions * 100line was placed outside theif/elseguard block (line 568 before this fix). This overwrites theaccuracy = 0safety value set in theifbranch, then immediately raisesZeroDivisionErrorwhentotal_predictions == 0.NameError:
clean_accuracywas only assigned inside theelsebranch. When theifbranch executes (i.e.total_predictions - invalid_responses == 0),clean_accuracywas never defined, causingNameError: name 'clean_accuracy' is not definedon the subsequentprintcall.Note: the companion method
save_results()already handles both variables correctly in both branches — this fix bringsprint_results()into alignment with that implementation.Solution
accuracyassignment outside theif/elseblock.clean_accuracy = 0in theifbranch, matching the pattern already used insave_results().Additional fixes
"unale to parse"→"unable to parse"(inOpenAICloseSetClsEvaluator.parse_gpt_response_evaluateandOpenAIObjectCaptioningEvaluator.parse_gpt_response_evaluate).Testing
Manually verified both bugs with a minimal reproducer: