LittlePlyResearch notebook

test_curriculum_loader.py

python · 15 lines · Exact bytes

Line 1 ↗
Version & provenance · data-cm7

Recorded SHA-256 ff239f26d36474e214192769b4f0aed44b8540c9d45c2bcb4fdde40447c8940aRendered SHA-256 ff239f26d36474e214192769b4f0aed44b8540c9d45c2bcb4fdde40447c8940a

Apache-2.0 original project code; dependencies retain their own licenses. License notes. Line links are stable within this snapshot. CM-7 completed implementation source; original and public rendered hashes recorded. Host-specific paths use /work placeholders; inspect reproduction instructions before running. Separate Rust helper retains its GPL license.

1import unittest
2import numpy as np
3from curriculum_loader import apply_tie,DTYPE,SCHEDULE_DTYPE
4from expand_theory import board_from_row
5from build_curriculum import c,phase
6class Tests(unittest.TestCase):
7    def test_ties(self):
8        r=np.zeros((),dtype=DTYPE);m={'tied_target_triples':[[1,2,64],[3,4,68]]}
9        apply_tie(r,m,1);self.assertEqual(r['y'].tolist(),[3,4,68]);self.assertEqual(r['x'][-2:].tolist(),[3,4]);self.assertEqual(SCHEDULE_DTYPE.itemsize,7)
10    def test_roundtrip(self):
11        b=c.chess.Board('8/8/7k/8/6RP/5r2/6K1/8 b - - 0 94');e=c.example(b,next(iter(b.legal_moves)),0)
12        r=np.zeros((),dtype=DTYPE);r['x']=e['input_ids'];r['fullmove']=94;r['key']=np.frombuffer(c.position_key(b),dtype=np.uint8)
13        self.assertEqual(board_from_row(r).fen(),b.fen());self.assertEqual(phase(np.array([r]))[0],2)
14if __name__=='__main__':unittest.main()
15