Exemple #1
0
def exp1():
    global rmem
    rmem = RMem.run(operands=range(1, 4),
                    startc=(None, '+', 1, None, 3),
                    ndups=2,
                    niters=1000)
    pr(rmem.lsteps)
Exemple #2
0
 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, '+')])
Exemple #3
0
 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
Exemple #4
0
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)
Exemple #5
0
 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)
Exemple #6
0
    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)
Exemple #7
0
 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
Exemple #8
0
 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)
Exemple #9
0
 def test_count_columns(self) -> None:
     n = self.quick_test(RMem.make_class((WithCountColumns, RMemAbs)),
                         #niters=100,
                         #termination_threshold=3
                         )
     self.assertGreaterEqual(n, 2)
Exemple #10
0
 def test_sequential_salt(self) -> None:
     n = self.quick_test(RMem.make_class((WithSequentialSalt, RMemAbs)), )
     self.assertGreaterEqual(n, 5)
Exemple #11
0
 def test_random_salt(self) -> None:
     n = self.quick_test(RMem.make_class((WithRandomSalt, RMemAbs)), )
     self.assertGreaterEqual(n, 8)
Exemple #12
0
 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)