Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Languages:
English
ArXiv:
License:
CodeLens / verification /smoke_test.py
William-Li's picture
Upload folder using huggingface_hub
9379442 verified
Raw History Blame
1.13 kB
"""Check both reward formulas using tiny, self-contained synthetic tasks."""
import json
import kodcode_reward
import taco_leetcode_reward
truth = {'test_code': 'from solution import add\ndef test_one():\n assert add(1,2)==3\ndef test_two():\n assert add(-1,1)==0\n',
'test_functions': ['test_one', 'test_two']}
good = 'def add(a,b):\n return a+b\n'
bad = 'def add(a,b):\n return 0\n'
k_good = kodcode_reward.compute_score('smoke', good, truth)
k_bad = kodcode_reward.compute_score('smoke', bad, truth)
assert k_good['score'] == 1 and k_bad['score'] == 0 and k_bad['pass_frac'] == 0.5
truth = {'mode': 'function', 'entry_point': 'add', 'tests': [
{'args': [1, 2], 'output': 3}, {'args': [-1, 1], 'output': 0}]}
t_good = taco_leetcode_reward.compute_score('smoke', good, truth)
t_bad = taco_leetcode_reward.compute_score('smoke', bad, truth)
assert t_good['score'] == 1 and t_bad['score'] == 0.4, (t_good, t_bad)
print(json.dumps({'kodcode': {'full': k_good['score'], 'half': k_bad['score']},
'taco_leetcode': {'full': t_good['score'], 'half': t_bad['score']}, 'status': 'PASS'}))