Datasets:
Download verification/smoke_test.py from CodeLogic-Team/CodeLens: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/datasets/CodeLogic-Team/CodeLens/resolve/28a5abc4fc62e07d55b7d0d718e90ff1124b9e3e/verification/smoke_test.py
- Command line
-
hf download hf://datasets/CodeLogic-Team/CodeLens@28a5abc4fc62e07d55b7d0d718e90ff1124b9e3e/verification/smoke_test.py
-
curl -L -o smoke_test.py https://huggingface.co/datasets/CodeLogic-Team/CodeLens/resolve/28a5abc4fc62e07d55b7d0d718e90ff1124b9e3e/verification/smoke_test.py
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'})) | |