Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/train/omega-llm/tools/combined/experiment/test_selection.py # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / train / omega-llm / tools / combined / experiment / test_selection.py` 54 lines ยท 2105 bytes Raw Blame History 1 """Controls independent of the 80 final tasks. Run with python3 -m unittest test_selection.""" 2 import unittest 3 from unittest.mock import patch 4 5 from selection import choose, disagreement 6 7 8 class MockEngine: 9 def predict(self, body, xs): 10 return [(int(x[0] == 9 and body == b"long"),) for x in xs] 11 12 13 class Controls(unittest.TestCase): 14 fixed = [(i,) for i in range(8)] 15 pool = [(8,), (9,), *fixed] 16 17 def check_run(self, generate, oracle=lambda x: (0,), adaptive=True): 18 seen=[] 19 def query(x): 20 self.assertNotIn(x,seen) 21 seen.append(x) 22 return oracle(x) 23 with patch("selection.candidates",side_effect=generate): 24 result=choose(MockEngine(),self.fixed,self.pool,query,adaptive) 25 self.assertEqual(len(seen),8) 26 return result,seen 27 28 def test_disagreement(self): 29 self.assertEqual(disagreement([0,0,1,1]),4) 30 self.assertEqual(disagreement([None,0,0,0]),3) 31 result, xs = self.check_run(lambda *_: [("sketch",b"s"),("synth",b"long")], 32 lambda x:(int(x==(9,)),)) 33 self.assertEqual(xs[4],(9,)) 34 self.assertEqual(result[:2],(b"long","synth")) 35 self.assertEqual(xs[5:],self.fixed[4:7]) 36 37 def test_tie_order_and_shortest(self): 38 result,xs=self.check_run(lambda *_: [("first",b"aa"),("second",b"bb"),("short",b"s")]) 39 self.assertEqual(xs,self.fixed) 40 self.assertEqual(result[:2],(b"s","short")) 41 result,_=self.check_run(lambda *_:[("first",b"aa"),("second",b"bb")],adaptive=False) 42 self.assertEqual(result[:2],(b"aa","first")) 43 44 def test_regeneration_and_abstention(self): 45 calls=[] 46 def after_empty(engine, rows): 47 calls.append(len(rows)) 48 return [] if len(rows)<6 else [("late",b"s")] 49 result,_=self.check_run(after_empty) 50 self.assertEqual(calls,[4,5,6]) 51 self.assertEqual(result[:2],(b"s","late")) 52 result,xs=self.check_run(lambda *_:[]) 53 self.assertEqual(result[:2],(None,"abstain")) 54 self.assertEqual(xs,self.fixed)