File tree 4 files changed +42
-2
lines changed
src/open_r1/rewards/api/code/unfoldml
4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 62
62
"peft>=0.14.0" ,
63
63
"pytest" ,
64
64
"python-dotenv" ,
65
+ "requests" ,
65
66
"ruff>=0.9.0" ,
66
67
"safetensors>=0.3.3" ,
67
68
"sentencepiece>=0.1.99" ,
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ def verify_triple_33(
95
95
v = res .json ()
96
96
except JSONDecodeError :
97
97
v = None
98
- print ( v )
98
+ return v
99
99
# else:
100
100
except HTTPError as he :
101
101
print (f"HTTP error: { he } " )
Original file line number Diff line number Diff line change
1
+ import unittest
2
+
3
+ from open_r1 .rewards .api .code .unfoldml .htgen import gen_triples_33 , verify_triple_33
4
+
5
+
6
+ class TestApi (unittest .TestCase ):
7
+ def test_gen_triples_structure ():
8
+ n_stmt = 3
9
+ for o in gen_triples_33 (n_examples = 1 , n_stmt = n_stmt ):
10
+ len_program = len (o ['program' ])
11
+ self .assertEqual (len_program , n_stmt )
12
+ def test_verify_triple_result ():
13
+ is_total = True
14
+ preconditions = "True" # trivial precondition
15
+ program = "v4 = (0 - v3)\n v3 = v3\n v5 = v4"
16
+ post_ok = "v5 == (0 - v3)" # post-condition that verifies
17
+ post_not_ok = "v5 == (1 - v3)" # post-condition that does not verify
18
+ # # should return True
19
+ o = verify_triple_33 (
20
+ is_total = is_total ,
21
+ preconditions = preconditions ,
22
+ program = program ,
23
+ postconditions = post_ok
24
+ )
25
+ res_ok = o ['prediction_is_correct' ]
26
+ self .assertEqual (res_ok , True )
27
+ # # should return False
28
+ o = verify_triple_33 (
29
+ is_total = is_total ,
30
+ preconditions = preconditions ,
31
+ program = program ,
32
+ postconditions = post_not_ok
33
+ )
34
+ res_not_ok = o ['prediction_is_correct' ]
35
+ salf .assertEqual (res_not_ok , False )
36
+
37
+
38
+
39
+ if __name__ == "__main__" :
40
+ unittest .main ()
Original file line number Diff line number Diff line change 9
9
reasoning_steps_reward ,
10
10
)
11
11
12
-
13
12
class TestRewards (unittest .TestCase ):
14
13
def test_accuracy_reward_correct_answer (self ):
15
14
"""Test accuracy_reward with a correct answer."""
You can’t perform that action at this time.
0 commit comments