def exp1(): global rmem rmem = RMem.run(operands=range(1, 4), startc=(None, '+', 1, None, 3), ndups=2, niters=1000) pr(rmem.lsteps)
def test_as_abs_painters(self) -> None: canvas = Canvas.make_from((1, None, 1, '=', 2)) rmem: WithAdjacentRelativePainters = RMem.make_instance( # type: ignore[assignment] (WithAdjacentRelativePainters, LinearClarityWeight)) p = (Match(1), Right(1), '+') self.assertCountEqual(rmem.as_abs_painters(canvas, p), [(1, 2, '+'), (3, 4, '+')])
def testCountColumns(self) -> None: rmem = RMem.make_instance((WithCountColumns, RMemAbs)) rmem.absorb_canvases(self.eqns) #print(rmem.niters) for cue in self.cues: #print(rmem.regenerate(cue)) pass
def xp_single(): global rmem rmem = RMem.run(operands=range(1, 2), operators=('+'), startc=(None, '+', None, None, None), ndups=1, niters=1000) pr(rmem.lsteps)
def test_with_random_salt(self) -> None: rmem: WithRandomSalt = \ RMem.make_instance((WithRandomSalt, RMemAbs)) # type: ignore[assignment] eqn = (1, '+', 1, '=', 2) self.assertEqual( len(as_tuple(rmem.prep_absorb(eqn))), 15 # prepended rmem.nsalt random numbers ) self.assertEqual(as_tuple(rmem.prep_regen(eqn)), (None, ) * 10 + eqn)
def test_with_sequential_salt(self) -> None: rmem: WithSequentialSalt = \ RMem.make_instance((WithSequentialSalt, RMemAbs)) # type: ignore[assignment] eqn = (1, '+', 1, '=', 2) self.assertEqual(as_tuple(rmem.prep_absorb(eqn)), (1, 2, 3, 4, 5) + eqn) self.assertEqual(as_tuple(rmem.prep_regen(eqn)), (None, None, None, None, None) + eqn)
def make_rmem(self) -> RMem: if isinstance(self.rmem, RMem): return self.rmem else: if isinstance(self.rmem, tuple): rmem = RMem.make_instance(self.rmem, **self.kwargs) else: rmem = self.rmem.make_instance(**self.kwargs) rmem.absorb_canvases(self.make_initial_canvases()) return rmem
def test_full_table_with_dups(self) -> None: # TODO Run a Cartesian test on these parameters and save the # results. cls = RMem.make_class((WithAbsolutePainters, WithNDups, Absorb, LinearClarityWeight, Regenerate)) counter = eqn_test( rm=cls, seed=1, niters=20, n_per_eqn=10, n_eqns=50 # 3, 1, 20, 10, 50 --> num_correct = 10, 22-Jan-2022 ) num_correct = sum(counter.values()) # lo('NUMC', num_correct) self.assertGreaterEqual(num_correct, 2)
def test_count_columns(self) -> None: n = self.quick_test(RMem.make_class((WithCountColumns, RMemAbs)), #niters=100, #termination_threshold=3 ) self.assertGreaterEqual(n, 2)
def test_sequential_salt(self) -> None: n = self.quick_test(RMem.make_class((WithSequentialSalt, RMemAbs)), ) self.assertGreaterEqual(n, 5)
def test_random_salt(self) -> None: n = self.quick_test(RMem.make_class((WithRandomSalt, RMemAbs)), ) self.assertGreaterEqual(n, 8)
def test_with_ndups(self) -> None: rmem: WithNDups = \ RMem.make_instance((WithNDups, RMemAbs), ndups=3) # type: ignore[assignment] eqn = (1, '+', 1, '=', 2) self.assertEqual(rmem.prep_absorb(eqn), eqn * 4) self.assertEqual(rmem.prep_regen(eqn), (None, ) * 5 * 3 + eqn)