Repository navigation
Make float_equiv's warning and docstring state the value it returns - #4356
buzzedaldrinx86-creator wants to merge 2 commits into
Conversation
Addresses item 1 of stanford-crfm#4340. No scoring behaviour changes. float_equiv returns 0.0 when either value cannot be parsed as a float, but its runtime warning and docstring both said it returns 1.0 when both values are non-floats. The warning and docstring now describe what the code does. Adds a test that pins the existing return values. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e docstring The test added earlier pins return values, which this PR does not change, so it passed on main. The new test patches hwarn and asserts that the warning names the value actually returned; it fails on main and passes here. The docstring said the function "always" returns 0.0 for non-floats. Non-str inputs such as None reach the outer except and return 1.0, so the sentence now describes the string case only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Pushed a follow-up after a second look at my own PR. The test I first added only pinned return values, which this PR doesn't change, so it passed on |
|
Gentle ping on this one when there's time, @yifanmai. It only changes |
Addresses item 1 of #4340. No scoring behaviour changes.
conv_fin_qa_calc_metrics.float_equivreturns0.0when either value cannot be parsed as a float, but its runtime warning saysfloat_equiv returning 1.0 because both values are non-floats, and the docstring says the same. Anyone reading the logs to understand a score sees "returning 1.0" while the metric receives0.0, and "both" while the guard isss1 is None or ss2 is None.This PR takes the smallest option from the issue: the warning and the docstring now describe what the code does.
float_equiv returning 0.0 because at least one value is a non-floattest_conv_fin_qa_calc_metrics.py, which pins the existing return values (equal floats 1.0, different floats 0.0, any non-float 0.0), so a later change to this path is a visible decision.I did not change the returned value:
1.0may have been the original intent, but switching it would alter existing ConvFinQA scores, which is a maintainer decision. Theexcept Exception: return float(str1 == str2)fallback is also left alone. Happy to follow up on either if you want a different direction.Checked
The function bodies from
main(63754d05) and from this branch were executed with HELM's imports stubbed: every return value is identical before and after, and the warning now states the returned value (before: stated 1.0, returned 0.0).black --check(line length 120) andflake8pass on the two files. I have not run the full HELM test suite locally.🤖 Generated with Claude Code